Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Multitasking problem - can't use the value returned by bgetc

Status
Not open for further replies.

Andrew83

Newbie level 2
Joined
Nov 5, 2008
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,291
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 :

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

Re: Multitasking problem

Hello. Try to create a fixed string, and compare the receive register to her. If equal do that....
Regards
 

Re: Multitasking problem

Thank you !:idea:
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top