View previous topic :: View next topic |
Author |
Message |
Ikk06
Joined: 30 Nov 2009 Posts: 6
|
How to initialize a uart |
Posted: Mon Nov 30, 2009 12:28 pm |
|
|
Hi I am new to pic c programming and I was wondering if anybody knows how to initialize the uart for asynchronous transmission on the pic18f252. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Ikk06
Joined: 30 Nov 2009 Posts: 6
|
|
Posted: Wed Dec 02, 2009 8:56 am |
|
|
When I checked the datasheet for my pic it said that I had to initialize the SPBRGH and the TXSTA. Is that not required to get the pic to send a message to the pc?
What if you wanted to connect another device to the pic such as a button, so that when you press the button a signal is sent to the pc? |
|
|
Ttelmah Guest
|
|
Posted: Wed Dec 02, 2009 9:55 am |
|
|
This is the fundamental difference between a compiler, and assembler. The compiler does a lot of the basic 'housekeeping' for you. So (for instance), you can just declare a variable, and the compiler decides where to actually put it in memory, and keeps track of it as you work. Similarly fo the UART, you just use the '#use rs232' line, and then getc, and putc to read/write data, and the compiler sets all the registers for you.
The button, is a separate thing. All you do, is input the bit value, and when it changes, or (better for a real button), when it has stayed the 'same' for a number of mSec, rsend your message.
Best Wishes |
|
|
|