In previous post, we showed a DIY prototyping board for PIC18F2550. That board has a block of RS-232 to TTL converter but it was not tested. We will test that block here separately.
CCS PICC has a built-in library of RS-232. It doesn't need to configure all related registers in SFR to make this module work. Its primary task is to add the #use rs232() directive in source code. This directive needs the #use delay(clock=x) directive to be declared first. For example,
C directive showed above inform the compiler to use 4MHz clock frequency. Default UART is uart1 for most of PIC micro-controller that come with USART module inside. The baud rate is set to 9600.
UART communication for 8-bit are RC6 for transmission (Tx), and RC7 for reception (Rx). UART data I/O functions are just like the ANSI C library function. For example printf() is use for outputting ASCII data from micro-controller from its Tx pin. Other ANSI C functions are usable in CCS PICC such as getc(), putc(), kbhit(), etc.
This example will show how to use these RS-232 functions with PIC18F2550 micro-controller.
I tested this example on my prototyping board.
Program testing on prototyping board |
Host PC and PIC18F2550 side sending/receive data |
I run this testing using a desktop PC with COM port on Windows 7 64-bit. The serial terminal showed above is a part of CCS PICC compiler IDE.
No comments:
Post a Comment