Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC18F & C Programming

Status
Not open for further replies.

mikesmixes777

New Member
HI,

I am wanting to start learning to program PIC's with C. I have a PIC18F252.
I have the ISP working. I am using MPLAB with C18 compiler.

What documents or tutrorials are available to learn how to address the USART and do A/D conversions using "C" ?

Any help would be greatly appreciated.
Mike
 
There is some example code in the directory where you installed the C18 compiler:
C:\MCC18\example\users_guide
NOTE: You may need to have specified that the samples be included when you installed the C18 compiler.
Other useful things:
C:\MCC18\doc\periph-lib
C:\MCC18\example\getting_started
 
Last edited:
Have you used these modules before?

Well you can use a library function to set up the UART or ADC, which personally I do not recommend because if you don't understand everything it's doing to the letter then there's a significant chance you're not going to be using it right. If you DO know exactly what you want to do, then just assign the reg directly. That's what most people do.

I have always just looked up the module functionality and assigning them in C is straightforward:
ADCON=0b11110000;

You will probably need to write an interrupt handler, that's in a format specific to a particular C compiler. The syntax is different for PICC18 and MCC18.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top