View previous topic :: View next topic |
Author |
Message |
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
How to properly declare UART on PIC24FJ |
Posted: Thu Apr 25, 2019 6:54 am |
|
|
Device is PIC24FJ1024GB610
CCS V5.078
I'm trying to port a currently working code from PIC18F to PIC24FJ and can't figure out how to properly declare the UARTs
I'm using this code on PIC18F67J50
Code: | #use rs232(UART1,stream=GSM,NOINIT)
#use rs232(UART2,stream=GPS,NOINIT)
|
But in PIC24FJ doesn't work.
Can be something related to PPS? (Peripheral Pin Select) _________________ Electric Blue |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Thu Apr 25, 2019 7:07 am |
|
|
don't use that PIC but have seen a lot of posts.....
hint..
NEED to declare the PPS stuff BEFORE the UARTs....
try 'searching' , there's posts here about it....even a 'sticky' !
Jay |
|
|
E_Blue
Joined: 13 Apr 2011 Posts: 417
|
|
Posted: Thu Apr 25, 2019 7:13 am |
|
|
Yes, I added the following code and works ok.
Code: | #pin_select U1TX=PIN_B6
#pin_select U1RX=PIN_B7
#pin_select U2TX=PIN_B0
#pin_select U2RX=PIN_B1
|
Now I'm must to port a lot of #asm code to C.
There is more than 100 #asm #endasm in the code, this is going to take some time. _________________ Electric Blue |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Thu Apr 25, 2019 8:46 am |
|
|
Yes. What does the ASM actually 'do'?. 90% of ASM can be done instead with
#byte and #bit and C code. The only stuff that can't, is going to be radically
different on a PIC24 (different instruction set...). |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1353
|
|
Posted: Thu Apr 25, 2019 8:03 pm |
|
|
E_Blue wrote: | Yes, I added the following code and works ok.
Code: | #pin_select U1TX=PIN_B6
#pin_select U1RX=PIN_B7
#pin_select U2TX=PIN_B0
#pin_select U2RX=PIN_B1
|
|
Quick note. If I remember correctly we use this chip on our dev board (or a close relative if not). You only have to specify PPS for Uarts 1,2,3, and 4. Uart 5 and Uart6 are hard pinned and won't need PPS. |
|
|
|