View previous topic :: View next topic |
Author |
Message |
louwi_138
Joined: 17 Nov 2012 Posts: 23
|
RS232 hardware configuration // PIC18f452 // picc PCB 4.110 |
Posted: Fri Sep 13, 2013 12:56 am |
|
|
Hello,
I configured my pic as PLL active with 10MHz witch make it run at 40MHz
but when I tested the communication it don't work as it should be.
I think that the baud was not well configured.
This is my configuration for the rs232 hardware module:
Code: |
RCSTA = 0x90;
TXSTA = 0x22;
SPBRG = 64; // 9600 with 10Mhz & x4 PLL
TXREG = 0; // dummy write
RCIE=1;
|
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Fri Sep 13, 2013 1:48 am |
|
|
Just use #use RS232.
Directly setting register is not really the way that CCS is designed to work. |
|
|
louwi_138
Joined: 17 Nov 2012 Posts: 23
|
|
Posted: Fri Sep 13, 2013 4:19 am |
|
|
Ttelmah wrote: | Just use #use RS232.
Directly setting register is not really the way that CCS is designed to work. |
I know that but it wil not activate the hardware module cause it's a software solution since I can shoose what ever pins I want for the rs232 communication ! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Fri Sep 13, 2013 4:37 am |
|
|
You misunderstand #use RS232.....
_If_ you select the hardware pins, it sets up the hardware port. It _only_ switches to being a 'software solution', if you use pins where there is no hardware.
#use RS232, programs the UART.
Even better, if you use the UART name it selects the UART automatically. So:
#USE RS232(UART1, Baud=9600, parity=N, ERRORS)
sets up UART1 ready for use. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Fri Sep 13, 2013 6:30 am |
|
|
BTW: unless you like spending extra $$ on antique pics
have you considered the 4520 ?? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Fri Sep 13, 2013 8:33 am |
|
|
Agreed. A good point. Many of the 'old' PIC's have been superceded by models that use less power, cost less, and have improved features. The 452, is a classic example of such an 'older' chip.
Best Wishes |
|
|
|