Andrew83
Newbie level 2
Multitasking problem
Hello !
I'm trying to ma a multitasking application.
One of the tasks is to receive a character over serial and convert it co binary form.
The problem is this : i can't use the value returned by bgetc() in the check_SERIAL() function.
I'm using pic18f452 @ 10 MHZ and CCS C compiler version 4.057.
Here is the code :
Any ideas ?
Thank you very much !!
Hello !
I'm trying to ma a multitasking application.
One of the tasks is to receive a character over serial and convert it co binary form.
The problem is this : i can't use the value returned by bgetc() in the check_SERIAL() function.
I'm using pic18f452 @ 10 MHZ and CCS C compiler version 4.057.
Here is the code :
Code:
#int_rda
void serial_isr() {
int t;
output_toggle(pin_b1); //debug
buffer[next_in]=getc();
t=next_in;
next_in=(next_in+1) % BUFFER_SIZE;
if(next_in==next_out)
next_in=t; // Buffer full !!
}
BYTE bgetc() {
BYTE c;
output_toggle(pin_b2); // debug
while(!bkbhit) ;
c=buffer[next_out];
next_out=(next_out+1) % BUFFER_SIZE;
return(c);
}
void check_SERIAL( void)
{
char i,d;
if(gc_IRTRANSMIT_timer)
{
output_toggle(pin_b3);
return;
}
else
{
gc_IRTRANSMIT_timer = IRTRANSMIT_TIMER_TICKS;
output_toggle(pin_b4); //debug
for(i = 0; i < 8; i++)
{
output_toggle(pin_b5); //debug
if( bgetc() & 0x80)
d='1';
else
d='0';
bgetc() <<= 1;
cmd[i]=d;
}
cmd[8]=0;
output_toggle(pin_b6); //debug
printf("%s",cmd);
}
}
Any ideas ?
Thank you very much !!