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 support@ccsinfo.com

use rs232(transmit_buffer, receive_buffer

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



Joined: 30 Sep 2003
Posts: 89

View user's profile Send private message

use rs232(transmit_buffer, receive_buffer
PostPosted: Fri Jan 10, 2014 3:04 pm     Reply with quote

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: 1319

View user's profile Send private message

PostPosted: Fri Jan 10, 2014 7:07 pm     Reply with quote

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: 19244

View user's profile Send private message

PostPosted: Sat Jan 11, 2014 2:24 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Jan 11, 2014 4:28 am     Reply with quote

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

View user's profile Send private message

use rs232(transmit_buffer, receive_buffer
PostPosted: Mon Jan 13, 2014 8:33 am     Reply with quote

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
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