CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC24FJ256GB106 int rda

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Aycan



Joined: 02 Apr 2004
Posts: 13
Location: TURKEY

View user's profile Send private message Send e-mail

PIC24FJ256GB106 int rda
PostPosted: Thu Jul 13, 2017 5:26 am     Reply with quote

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: 9226
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Jul 13, 2017 5:59 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Jul 13, 2017 6:16 am     Reply with quote

use fgetc(lcd) and fgetc(gsm_modem) so it knows which uart to get a character from.
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Thu Jul 13, 2017 6:17 am     Reply with quote

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.... Smile
Aycan



Joined: 02 Apr 2004
Posts: 13
Location: TURKEY

View user's profile Send private message Send e-mail

PostPosted: Thu Jul 13, 2017 6:31 am     Reply with quote

Problem was solved by fgetc().
Thank you all for your valuable help.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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