View previous topic :: View next topic |
Author |
Message |
Eugeneo
Joined: 30 Aug 2005 Posts: 155 Location: Calgary, AB
|
4th UART interrupt not working |
Posted: Sat Dec 20, 2014 2:13 am |
|
|
Hi guys, I thought maybe somebody has run into this issue before. I'm using the PIC24FJ128GA306 with CCS PCM v5.017.
All four uarts are configured to send and receive using interrupts. All of them work except for RDA4, which is interrupt uart 4 on data reception. Here are a couple of things I've tried.
Swapping the IO pins (re-mappable) to ones that are confirmed working on another uart.
Checking to ensure RX interrupt enable is set correctly in the assembly listing (enable_interrupts(INT_RDA4)).
Ensured the correct value is placed to interrupt on 1 byte.
Verified the code is NOT executed in the interrupt.
Verified there is no pre-existing data in the buffer at startup that may cause issues (long shot).
I'm left scratching my head on this one. Any thoughts are greatly appreciated. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Sat Dec 20, 2014 4:59 am |
|
|
Have just had a quick look, and can add the following:
It does correctly put the vector in the IVT.
It does correctly set the priority.
It does correctly adjust the pin mapping.
A quick look then shows it is not enabling UART4.
Try:
Code: |
#word U4MODE=getenv("SFR:U4MODE")
#bit UART4EN=U4MODE.15
//then before enabling interrupts, add
UART4EN=TRUE;
|
No guarantees, haven't made sure there is nothing else wrong, but this one 'stands out'. |
|
|
Eugeneo
Joined: 30 Aug 2005 Posts: 155 Location: Calgary, AB
|
|
Posted: Sat Dec 20, 2014 7:02 pm |
|
|
Thanks for the response.
I've tried what you suggested with no luck. As you mentioned, nowhere in the listing is 0x02B0.15 or 0x02B1.7 set. The defaults value is 0 for ports 1,2 and 3, and they are working fine.
I'm not even sure what to try next.
Code: |
#word U4MODE=getenv("SFR:U4MODE")
#bit UART4EN=U4MODE.15
//then before enabling interrupts, add
UART4EN=TRUE;
|
|
|
|
Eugeneo
Joined: 30 Aug 2005 Posts: 155 Location: Calgary, AB
|
|
Posted: Sun Dec 21, 2014 2:04 am |
|
|
Update:
I checked the pin mapping. It looks like CCS 5.016 does not produce the code for specifically uart4 receive pin re-mapping. My compiler is out of date. Is there is revision log that I can look at to see if this fix has been applied somewhere in the newer version?
Thanks for the help.
Below is the ASM code to make it work for RP10 or PIN_F4.
Code: |
#PIN_SELECT U4TX = PIN_F5
#PIN_SELECT U4RX = PIN_F4
#use rs232(UART4, stream=SP4, baud=19200, PARITY=N, BITS=8, errors)
....
// Messy but just checking to see if this works because it was not in the listing
#asm
MOV #0x3F0A,W0 // Map RP10 or PIN_F4 to uart 4 rx
MOV W0,0x06B6 // RPINR27 Uart4 CTS/RX reg
#endasm
|
|
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Mon Dec 22, 2014 9:44 am |
|
|
Except they only ever list about 1/10th of what actually changes....
However can say I tried with 5.028, and this did correctly set the pin selection register, but it still didn't work in MPLAB. |
|
|
|