![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Kumar Sin
Joined: 15 Jan 2015 Posts: 2 Location: 051 Village Dr., Buena Park, CA
|
#use rs232 syntax for ccs |
Posted: Thu Jan 15, 2015 9:40 am |
|
|
I have a project which has few files. One of the files has a syntax #use rs232 to initialize the usart1. Given below.
Code: | #use rs232(uart1, baud=19200, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8)
#int_RDA
void RDA1_isr(void)
{
UCHAR receive_byte;
......................
......................
} |
I have another #use syntax in another file which initialize the usart2.
Code: | #use rs232(uart2, baud=19200, parity=N, xmit=PIN_G1, rcv=PIN_G2, bits=8)
#int_RDA2
void RDA2_isr(void)
{
// Transfer the received byte from the UART to the DACT receive buffer
DACT_receive_buffer[DACT_receive_buffer_load_index] = RCREG2;
.............................
.............................
}
|
when I compile the project I get this error message
--- Info 300 "C:\My_Test_HCA\HCA\Code\FS1K_intrpt.c" Line 448(5,8): More info: First Declaration of STDIN
*** Error 31 "C:\My_Test_HCA\HCA\Code\pic_RemPanel.c" Line 730(5,74): Identifier is already used in this scope
1 Errors, 1 Warnings.
Build Failed.
If I remove any one of the #use rs232(.............. ) syntax, it compiles well. Appreciate your help. I am new to this compiler. _________________ Kumar |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 15, 2015 12:46 pm |
|
|
The last #use rs232() line in the file controls the configuration for all
putc, getc, printf, etc., that occur after that line.
When using multiple #use rs232() statements, you should add the Stream
parameter to each statement. Give each #use rs232() statement a
unique Stream name, such as COM1, COM2, GPS1, TERM1, or whatever
you want. Then use fputc, fgetc, fprintf, etc. to specify the stream name
for each function. See the CCS manual. |
|
![](templates/subSilver/images/spacer.gif) |
Kumar Sin
Joined: 15 Jan 2015 Posts: 2 Location: 051 Village Dr., Buena Park, CA
|
|
Posted: Thu Jan 15, 2015 1:12 pm |
|
|
I am not using putc, getc. instead I use RCREG1 and RCREG2 registers defined in PIC18F86J11_ccs.h file to received the data from usart1 and usart2.
Code: | #use rs232(uart1, baud=19200, parity=N, xmit=PIN_C6, rcv=PIN_C7, bits=8)
#int_RDA
void RDA1_isr(void)
{
UCHAR receive_byte;
// Read the received byte from the UART??
receive_byte = RCREG1;
.............
}
#use rs232(uart2, baud=19200, parity=N, xmit=PIN_G1, rcv=PIN_G2, bits=8)
#int_RDA2
void RDA2_isr(void)
{
// Transfer the received byte from the UART to the DACT receive buffer
DACT_receive_buffer[DACT_receive_buffer_load_index] = RCREG2;
........
} |
This code worked previously, may be older version of the compiler. The previous programmer wrote this code and worked. Without modifying it, I used 45 days trial version of the compiler to compile this code. I get this error message. May be old version of the compiler tolerate this??? _________________ Kumar |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 15, 2015 1:45 pm |
|
|
I can't test it without knowing the old compiler version.
If you use streams with vs. 5.036, then it will compile with no errors. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19375
|
|
Posted: Thu Jan 15, 2015 2:49 pm |
|
|
Still just add the stream identifier. This doesn't stop the hardware registers being used, and will allow the two initialisations.
As a comment, _either_ use 'uartx', _or_ use the pin numbers. Not both.
As a further comment, why not use getc?.
Your code as written, is dangerous. Since you don't have 'ERRORS' in the RS232 declaration (and are not using getc), if a UART error occurs, the UART _will_ become hung. The rule of thumb is that you _must_ either have 'ERRORS', or handle UART errors yourself. If you want to do register accesses 'fair enough', but if you are doing these, then your code needs to add error handling. You need something like:
Code: |
#INT_RDA
void RDA1_ISR(void)
{
UCHAR receive_byte;
// Read the received byte from the UART??
receive_byte = RCREG1;
if (OERR)
{
CREN=FALSE;
CREN=TRUE;
}
//other code.
}
|
As an absolute minimum. With suitable defines for OERR, CREN etc.. You also depending on the UART, may need to handle FERR as well. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|