View previous topic :: View next topic |
Author |
Message |
foodwatch
Joined: 18 Apr 2006 Posts: 66
|
Need Help with RS232 Rx code in 18F4550 with Int_rda running |
Posted: Sun Nov 26, 2006 6:53 pm |
|
|
I am a C Newbie and need to get my 18f4550 to receive wireless data on rc7 using the internal UART. I need to accumulate this data (about 54 bytes) in a buffer. Most of the code I see online is using fancy functions that unfortunately I dont yet understand (I dont mind the extra typing). I have all the electrical stuff working just fine. I am working at 9600N81 with no flow control. Can anyone help with the irq routine that will simply allow the data to be captured to a buffer? Thanks |
|
![](templates/subSilver/images/spacer.gif) |
BOB_SANTANA
Joined: 16 Oct 2006 Posts: 110 Location: HOVE, EAST SUSSEX
|
|
Posted: Sun Nov 26, 2006 7:16 pm |
|
|
There is an example which comes with your complier SISR.c
it does exactly what you want
you would have to change the buffer size _________________ BOB_Santana ![Smile](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
foodwatch
Joined: 18 Apr 2006 Posts: 66
|
|
Posted: Sun Nov 26, 2006 7:33 pm |
|
|
Thanks Bob,This is the code I have been using but my lack of C experience is giving me fits with the irq functions and how they work.
I am trying to output the data to my lcd display, but dont really understand the "bgetc" function as it is written. The RS232 code seems to be working, but I was looking to printf(lcd_put,"\f%S",buffer); and have it display the data on my lcd so I can work out the protocol issues needed for reliable wireless transmission. What is supposed to happen when the buffer count is reached? |
|
![](templates/subSilver/images/spacer.gif) |
BOB_SANTANA
Joined: 16 Oct 2006 Posts: 110 Location: HOVE, EAST SUSSEX
|
|
Posted: Thu Nov 30, 2006 1:31 pm |
|
|
Dont know if you have got this sorted yet
But you can't use Code: | printf(lcd_put,"\f%S",buffer); |
As the data is not a string
The data is store in the 32 element array Code: | buffer[BUFFER_SIZE] |
So you need to read each element in the array where the data is
it uses next_out as a pointer to the data
As for the lcd part you could do something like assuming you wanted to
read the first elements of the array
Code: |
for(counter=0;counter < 8;counter++)
{
lcd_gotoxy(1+counter, 2); // Go to begining of 2nd Line
printf(lcd_putc,"%c",buffer[counter]);
}
|
_________________ BOB_Santana ![Smile](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
BOB_SANTANA
Joined: 16 Oct 2006 Posts: 110 Location: HOVE, EAST SUSSEX
|
|
Posted: Thu Nov 30, 2006 1:33 pm |
|
|
Sorry i meant the first 8 elements ![Cool](images/smiles/icon_cool.gif) _________________ BOB_Santana ![Smile](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
|