Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/07/09 13:06
Modified:
  04/07/09 13:19

Read: times


 
#164456 - reply Kai
Responding to: ???'s previous message
Below is a portion of the main code.
///////////////////////////////////////////////////////////////////////
while(1)
{
if (STATE==1)
{
OutChar('C');
OutChar('R');
OutChar(' ');
OutChar('1');
OutChar('8');
OutChar(' ');
OutChar('3');
OutChar('2');
OutChar(' ');
OutChar('1');
OutChar('7');
OutChar(' ');
OutChar('0');
OutChar(' ');
OutChar('1');
OutChar('9');
OutChar(' ');
OutChar('3');
OutChar('3');
OutChar(13);
i=0;
while(SBUF!=':')
{
while(!RI);
RI=0;
TrmBuf[i]=SBUF;
i++;
}

if((TrmBuf[0]=='A')&& (TrmBuf[1]=='C')&& (TrmBuf[2]=='K'))
{
STATE++;
}
else
{
STATE=1;
}
}
.
.
.
.
if (STATE == 2)
.
.
.
.
and so on
}
//////////////////////////////////////////////////////////////////////////////////////////////
outchar is used to send ASCII characters as following:

void OutChar(unsigned char c)
{
while(!TI);
TI=0;
SBUF=c;
}
//////////////////////////////////////////////////////////////////////////////////////////
TrmBuf is a array character use to store the receive ASCII character.
Then I have to check on receive character is either ACK or NCK to determine on next state.
Baudrate is 9600 for cmucam2 and 8051.
pool mode is used which means one instruction will feedback one message.
For example above, ASCII character of 'CR 18 44 17 2 19 31'is send then immediately either 'ACK' or 'NCK' is receive.
Similiar things are in the next few stage but ASCII characters are different in terms of number.
In the last stage, it contains the keyword to move the stepper motor in different direction.(when interrupt occurs the keyword is bring to ISR)
Timer 2 is used as counter and interrupt for every 1ms.
Stepper motor moves smoothly (which is not stated in above)just the operation cameraa is not working.
I have change the timer value but it still cant works. This struggles and tortures me very much T_T.




List of 40 messages in thread
TopicAuthorDate
how to avoid timer interrupt interrupts serial communication            01/01/70 00:00      
   Here the timing is relevant!            01/01/70 00:00      
   how to avoid timer interrupt interrupts serial communication            01/01/70 00:00      
      reply Kai            01/01/70 00:00      
         Do ms-class delays in any interrupt.            01/01/70 00:00      
            re: Per Westermark            01/01/70 00:00      
               ISR frequency * time significantly below 100%            01/01/70 00:00      
               Not sure, whether I got you...            01/01/70 00:00      
               That is not the main problem            01/01/70 00:00      
                  It's a common mistake...            01/01/70 00:00      
                     oops            01/01/70 00:00      
                        Long ISRs are no problem, unless...            01/01/70 00:00      
          instruction execution cycle/time in C language            01/01/70 00:00      
   ISR is set to 1ms but...            01/01/70 00:00      
      That is the problem            01/01/70 00:00      
         oops            01/01/70 00:00      
            What is the baud rate?            01/01/70 00:00      
               9600 baud            01/01/70 00:00      
                  He has got to be sitting in a interupt            01/01/70 00:00      
                     reply            01/01/70 00:00      
                        Many many more details needed!!            01/01/70 00:00      
                           reply Kai            01/01/70 00:00      
                              Further questions...            01/01/70 00:00      
                                 reply Kai            01/01/70 00:00      
                                    Who tells your micro how the stepper is to be moved?            01/01/70 00:00      
                                       reply            01/01/70 00:00      
                                          So, the stepper is running all the time?            01/01/70 00:00      
                                             ya...this is the purpose of having interrupt            01/01/70 00:00      
                                                Ok, then confirm this please...            01/01/70 00:00      
                                                   reply Kai            01/01/70 00:00      
                                                      Still delays in the ISR?            01/01/70 00:00      
                                                         reply per            01/01/70 00:00      
                                                      I suspect that your ISR is longer than 1msec!            01/01/70 00:00      
                                                         reply            01/01/70 00:00      
                                                         ISR code            01/01/70 00:00      
                                                            Post full ISR            01/01/70 00:00      
                                                               reply            01/01/70 00:00      
                                                                  Still not full ISR shown - and debounce?            01/01/70 00:00      
                                                                     Addendum            01/01/70 00:00      
   T_T            01/01/70 00:00      

Back to Subject List