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

two USART stream with different speed

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



Joined: 02 Feb 2010
Posts: 345

View user's profile Send private message

two USART stream with different speed
PostPosted: Wed Mar 09, 2011 3:35 pm     Reply with quote

Hello for All..
I've a few question about serial communication :
1. What is the best method for receiving serial stream ? (linear buffer with timer ISR ->Neutone example, circular buffering ->CCS example ...)
2. I've searching good topic for setup and manage CCS #INT_ISR.?
3. Any example for convert one protocol to other with different UART speed?
temtronic



Joined: 01 Jul 2010
Posts: 9134
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Mar 09, 2011 4:17 pm     Reply with quote

What's best for one application is not the best for all applications. Only you know the criteria and hardware for your application. Usually, using a ring buffer and interrupts will be the most used way to receive asynchronus serial data, but not 'carved in stone'.
There are several examples as well as Q&As about CCS's use it's ISR handling, again, how you implement it or part of it, depends on your specifics.
Your query about 'Conversion of protocols with different UART speeds' is unclear. Usually the protocol is fixed,encompassing the data stream format, timing, logic levels, hard pinout, etc. One normally doesn't change any of this unless you're into some very high security data transfers, usually to prevent 'hacking'. If this this not what you meant, please reprhrase the question.
kmp84



Joined: 02 Feb 2010
Posts: 345

View user's profile Send private message

PostPosted: Thu Mar 10, 2011 2:30 am     Reply with quote

thanks for join ... Yes my questions is not very clear and I wil put part of code for discussion...
Code:

   #include <18F452.H>
   #fuses HS,PROTECT,NOOSCSEN,NODEBUG,PUT,NOWDT,NOBROWNOUT,NOLVP,NOCPD,NOWRT,NOSTVREN,NOCPB
 //////////////////////////////////////
   #use delay(clock=11 059 200)                                                              //
   #use rs232(baud=1200,rcv=PIN_C7,xmit=PIN_C6,errors,enable=PIN_C4,STREAM=dispenser)        //
   #use rs232(baud=9600,rcv=PIN_B0,xmit=PIN_B1,STREAM=PC,errors,FLOAT_HIGH)     //
    ///////////////////////////////////////////////////////////////////////////////////////////

   #define buffer_size_pc  32
   #define buffer_size_ds  32
   // #define buffer_size_tmp 32
   
   #priority ext,rda
   
   //Global Variables.....
   int buffer_pc_rx [buffer_size_pc];
   int buffer_pc_tx [buffer_size_pc];
   //int buffer_temp  [buffer_size_tmp];
   int buffer_ds_rx [buffer_size_ds];
   int buffer_ds_tx [buffer_size_ds];
   int index_pc_rx;
   int index_ds_rx;
   int1 packet_pc;
   int1 packet_ds;
   int ext;
   int index_temp;
   int index_temp2;
   int rd;
   int temp_state = PUMP_State;
   int temp_gun =0x00;
   
 #int_timer1                 
   void TIMER1_isr()
   {
      disable_interrupts(int_TIMER1);
      packet_pc=1;
      index_pc_rx =0;
   }
   
 #int_ext
   void PC_ISR ()
   {
      ext = fgetc(PC);
      if(!packet_pc)                                           
      {  buffer_pc_rx[index_pc_rx] = ext;
         index_temp=index_pc_rx;
         if(++index_pc_rx == buffer_size_pc)
         { 
             index_pc_rx =0;
         }
         set_timer1(63500); //
         clear_interrupt(int_TIMER1);       
         enable_interrupts(int_TIMER1);   
      }
   }

 #int_timer3
 void timer3_isr ()
 {
      disable_interrupts(int_TIMER3);
      packet_ds=1;
      index_ds_rx =0;
 }
 
 #int_rda
   void rda_isr ()
   {
      rd=fgetc(dispenser);
      if(!packet_ds)
      {
         buffer_ds_rx[index_ds_rx]=rd;
         index_temp2=index_ds_rx;
         if (++index_ds_rx==buffer_size_ds)
         {
            index_ds_rx=0;
         }
     
         set_timer3(24933);
         clear_interrupt(int_TIMER3);       
         enable_interrupts(int_TIMER3);
         
      }
   }
   
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