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 CCS Technical Support

Use timer interrupts to start transmitting interrupts

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



Joined: 03 Dec 2008
Posts: 45

View user's profile Send private message

Use timer interrupts to start transmitting interrupts
PostPosted: Tue Jan 10, 2012 4:05 pm     Reply with quote

Is that possible to start a transmitting interrupts in a timer interrupt for sending out data once in certain time period.
Code:

#int_timer1
void time1_isr()
{
set_timer1(0xbf5);
enable_interrupts(int_tbe);
}

#int_tbe
void serial_isr() {
output_high(pin_a2);
if(t_next_in!=t_next_out)
   {
      putc(t_buffer[t_next_out]);
      t_next_out=(t_next_out+1) % T_BUFFER_SIZE;
   }
else
   disable_interrupts(int_tbe);
}

Thanks in advance for any help.
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Jan 10, 2012 5:05 pm     Reply with quote

ANSWER:
yes it should be possible
but ONE of your problems is it keep repeating in the timer isr
Code:


STATIC int1 TX_armed=0; // set this to '1' elsewhere in your program when you   
//have data you want to release on timer INT - this will enable it only
// ONCE and the send routine DISARMS the control flag when TX empty
// routine is done

#int_timer1
void time1_isr() {
    set_timer1(0xbf5);
    if (TX_ARMED){
        TX_ARMED=0;
        enable_interrupts(int_tbe);
     }
}
#int_tbe
void serial_isr() {
   output_high(pin_a2); // whatever
   if(t_next_in!=t_next_out)   {
       putc(t_buffer[t_next_out]);
       t_next_out++;   
       if(t_next_out==T_BUFFER_SIZE)  t_next_out=0;
    }
    else{
    tx_armed=0;
   disable_interrupts(int_tbe);
  }
}


i also cleaned up an inefficiency in the modulus % usage in the circular buffer.
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