View previous topic :: View next topic |
Author |
Message |
pfournier
Joined: 30 Sep 2003 Posts: 89
|
use rs232(transmit_buffer, receive_buffer |
Posted: Fri Jan 10, 2014 3:04 pm |
|
|
I just noticed that #use rs232 has the options receive_buffer and transmit_buffer. Has anyone used these options?
Up till now I have always used my own circular buffers, and I probably will still for large streams, but the new options look good for when I can't get to my serial interrupts quite on time and allow me to take in a few extra chars.
Thanks, _________________ -Pete |
|
|
jeremiah
Joined: 20 Jul 2010 Posts: 1358
|
|
Posted: Fri Jan 10, 2014 7:07 pm |
|
|
They have some interesting "features". For one, they overwrite the entire buffer and starts over once it fills up, so you have to keep the buffer from ever filling up or you will lose any remaining data that you didn't read quickly enough.
On 8 bit platforms, there are some interrupt variable corruption issues since the next_in/next_out params are 16bit and interrupts don't appear to be disabled. This isn't an issue on a PIC24 or dsPIC though as those are 16 bits. You can work around this by disabling interrupts while using putc and printf, but that defeats the purpose of ISR serial in my book.
I prefer a method similar to ex_sisr.c still to be honest. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19563
|
|
Posted: Sat Jan 11, 2014 2:24 am |
|
|
Agree with Jeremiah.
The new options don't gain you anything. They use serial interrupts, so will have exactly the same behaviour as the sisr type buffers "when I can't get to my serial interrupts quite on time".
They are fairly poorly implemented.
Best Wishes |
|
|
micro_debugger
Joined: 08 Oct 2009 Posts: 73
|
|
Posted: Sat Jan 11, 2014 4:28 am |
|
|
Hi,
Compiler: PCWH Version 5.011, processor PIC18F25K20
About 5 months ago, asking the CCS about usage of this option I received the following answer. If it helps you. I never used it.
///////////////////////////////////////////////////////////////
This message is a reply to CCS e-mail id: 3I2372
The RS232 functions work the same way they always have, they just use buffers instead if you enable them. If you want to use the receive or transmit buffers all you need to do is specify the size of the transmit and receive buffer and enable the global interrupt in you main code. If you are using a transmit buffer and the NOTXISR option you also need to call the putc_send(); function often in your code. For example something like the following:
Code: |
#include <18F25K20.h>
#use delay(internal=8MHz)
#use rs232(UART1, baud=9600, RECEIVE_BUFFER=100, TRANSMIT_BUFFER=100, TXISR)
void main()
{
char c;
enable_interrupts(GLOBAL);
printf("\r\nTesting RS232 PIC18F25K20\r\n\n");
while(TRUE)
{
if(kbhit())
{
c = getc();
putc(c);
if(c == '\r')
putc('\n');
else if(c == 0x08)
{
putc(' ');
putc(c);
}
}
}
}
|
Kind Regards |
|
|
pfournier
Joined: 30 Sep 2003 Posts: 89
|
use rs232(transmit_buffer, receive_buffer |
Posted: Mon Jan 13, 2014 8:33 am |
|
|
Thanks for the help.
I think I will start the interrupt routines I have used for years and then try some modifications to see what happens. There is not enough documentation on this at all. _________________ -Pete |
|
|
|