|
|
View previous topic :: View next topic |
Author |
Message |
Aycan
Joined: 02 Apr 2004 Posts: 13 Location: TURKEY
|
PIC24FJ256GB106 int rda |
Posted: Thu Jul 13, 2017 5:26 am |
|
|
PIC24FJ256GB106, ccs ver 5.070
I try to use isr for both of uarts in same time. Just one uart works that first declared, other not. Compiler doesn't create code for second declared uart in disassembly listing file as you see. Anyone has idea for fix this.
Code: | #include <24FJ256GB106.H>
#device ICD=TRUE
#device ICSP=3
#fuses NOWDT,NOPROTECT,NOJTAG,NOCKSFSM
#use delay(internal=32MHz)
#pin_select U1TX=PIN_F4
#pin_select U1RX=PIN_F5
#use rs232(UART1, baud=9600, errors, brgh1ok, stream=lcd)
#pin_select U2TX=PIN_D2
#pin_select U2RX=PIN_D1
#use rs232(UART2, baud=9600, errors, brgh1ok, stream=gsm_modem)
unsigned char rx1[64], rx2[64], chr1 = 0, chr2 = 0;
#INT_RDA
void rda_isr(void) {
rx1[chr1++] = getc();
}
#INT_RDA2
void rda2_isr(void) {
rx2[chr2++] = getc();
}
void main(void) {
setup_oscillator(OSC_INTERNAL, 32000000);
delay_ms(100);
enable_interrupts(INT_RDA);
enable_interrupts(INT_RDA2);
enable_interrupts(INTR_GLOBAL);
memset(&rx1, 0, sizeof(rx1));
memset(&rx2, 0, sizeof(rx2));
while (1) {
}
}
|
//// Disassembly Listing /////////
!#include <24FJ256GB106.H>
!#device ICD=TRUE
!#device ICSP=3
!#fuses NOWDT,NOPROTECT,NOJTAG,NOCKSFSM
!#use delay(internal=32MHz)
0x26E: CP0 W0
0x270: BTSC SR, #1
0x272: BRA 0x27C
0x274: REPEAT #0x3E7B
0x276: NOP
0x278: DEC W0, W0
0x27A: BRA NZ, 0x274
0x27C: RETURN
!#pin_select U1TX=PIN_F4
!#pin_select U1RX=PIN_F5
!#use rs232(UART1, baud=9600, errors, brgh1ok, stream=lcd)
0x200: BTSS U1STA, #0
0x202: BRA GETCH_BIU_1
0x204: PUSH U1STA
0x206: POP rs232_errors
0x208: MOV U1RXREG, W0
0x20A: BCLR U1STA, #1
0x20C: RETURN
!#pin_select U2TX=PIN_D2
!#pin_select U2RX=PIN_D1
!#use rs232(UART2, baud=9600, errors, brgh1ok, stream=gsm_modem)
!unsigned char rx1[64], rx2[64], chr1 = 0, chr2 = 0;
!#INT_RDA
!void rda_isr(void) {
0x20E: PUSH SR
0x210: PUSH RCOUNT
0x212: PUSH TBLPAG
0x214: MOV W0, [W15++]
0x216: MOV #0x2, W0
0x218: REPEAT #0xC
.
.
.
. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Thu Jul 13, 2017 5:59 am |
|
|
I don't use that PIC but any chance those pins are used for the ICSP or ICD or some other device that has a higher 'priority' over the pin usage?
Dang PICs have too many options these days !
Jay |
|
|
gaugeguy
Joined: 05 Apr 2011 Posts: 303
|
|
Posted: Thu Jul 13, 2017 6:16 am |
|
|
use fgetc(lcd) and fgetc(gsm_modem) so it knows which uart to get a character from. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Thu Jul 13, 2017 6:17 am |
|
|
Your problem is simple. You are not using both UART's....
Think about it. You call 'getc'. How does it know which UART to read from?.
Getc, by default always accesses 'STDIO', which is the first UART declared.
To use two UART's you need to be telling it which UART to use:
Code: |
#INT_RDA
void rda_isr(void)
{
rx1[chr1++] = fgetc(lcd);
}
#INT_RDA2
void rda2_isr(void)
{
rx2[chr2++] = fgetc(gsm_modem);
}
|
And similarly on any outputs.....
That is the whole point of stream names.
I see gaugeguy posted the same point while I was typing.... |
|
|
Aycan
Joined: 02 Apr 2004 Posts: 13 Location: TURKEY
|
|
Posted: Thu Jul 13, 2017 6:31 am |
|
|
Problem was solved by fgetc().
Thank you all for your valuable help. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|