enable_interrupts(INT_EXT_H2L);
}
The first state will be OFF, which is signaled by a zero
in the nextState value. The final tasks we will perform
within the init function include clearing the fremote flag
and enabling the external interrupt. A quick look at the
stick schematic reveals that the pushbutton I/O signal is
pulled up with a 10K resistor. The H2L in the interrupt
enable statement instructs the interrupt engine to fire
when the pushbutton logic level transitions from logically
high to logically low. The main loop of our prototyping
stick remote control application consists of a C language
switch mechanism that forms a mini state machine:
■ Screenshot 3. Binary patterns are usually sent
between remote control devices. These are simply
binary patterns that humans can read.
void main(void)
{
init();
while(TRUE)
{
switch(nextState)
{
case 0:
if(flags.fremote == 1)
{
disable_interrupts(INT_EXT);
delay_ms(100);
while(input(PBTN));
while(!input(PBTN));
for(aryIndex = 0;aryIndex <
3;aryIndex++)
{
fprintf(RADIO,”%c”,msgOFF
[aryIndex]);
}
fprintf(RADIO,” “);
output_high(RED_LED);
delay_ms(500);
output_low(RED_LED);
nextState = 1;
flags.fremote = 0;
while(!input(PBTN));
November 2014 57