|
|
View previous topic :: View next topic |
Author |
Message |
filjoa
Joined: 04 May 2008 Posts: 260
|
RS232 interruptions |
Posted: Mon Jun 14, 2010 4:12 pm |
|
|
Hi
If my MCU have two usarts I can use two interrutps for protocol Rs232?
My PIC is PIC18F25J11. My idea is use one for a GSM module and other for GPS. Because now I have other PIC with only one USART and I read information from the GSM module for polling and sometimes it fail...
This read from virtual port stay correct?
Code: |
fprintf(gsmport,"at\r");
delay_ms(500);
fprintf(gsmport,"at+cmgr=1\r");
delay_ms(100);
while (fgetc(gsmport)!='#');
do {
sms[i]=fgetc(gsmport);
i++;
}while (i<15);
|
PS: I put "i<15", because my message only have max 9 characters.
best regards |
|
|
Audi80
Joined: 07 Sep 2007 Posts: 41
|
|
Posted: Wed Jun 16, 2010 9:48 am |
|
|
You can make two serial interrupt routines like:
Code: | #use rs232(baud=9600, xmit=TX,rcv=RX,BRGH1OK,ENABLE=WR,UART1,STREAM=COMM,BRGH1OK)
#use rs232(baud=9600, xmit=TX2,rcv=RX2,BRGH1OK,ENABLE=WR2,UART2,STREAM=COMM2,BRGH1OK)
char a,b;
#INT_RDA
void communications(){
a=fgetc(COMM);
}
#INT_RDA2
void communications2(){
b=fgetc(COMM2);
} |
And use each one to a single rs232 input...
Hope this helps! |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Wed Jun 16, 2010 10:08 am |
|
|
A few comments about the USE RS232 declarations:
1. You don't need BRGH10K in the USE RS232 (certainly not twice).
2. Using the UART1 and UART2 declarations you shouldn't need the XMIT and RCV parameters.
3. Unless using half duplex you shouldn't need the ENABLE pin definition.
4. ERRORS needs to be included to prevent a lockup due to receive errors.
The below declarations should be sufficient if using two hardware USARTS:
Code: |
#use rs232(baud=9600,UART1,STREAM=COMM. ERRORS)
#use rs232(baud=9600,UART2,STREAM=COMM2, ERRORS)
|
Read pages 139-141 in the current CCS manual for more information on these. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
|
|
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
|