Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 232395

Forum Post: RE: Break USI interrupt before finish the routine

$
0
0

In case 4, when an ACK is received, you may set the state to 6, but then you do a break and exit the switch. It will be until next interrupt (which never comes, as you don't do any USI operation at this point) that the switch will be executed again and go to case 6.

To make it work, you should only break in case 4 when you want to exit the switch. if you want to fall through to case 6, then don't do a break:

      case 4: // Check Ack or Nack Rx               USICTL0 |= USIOE;               if (USISRL & 0x00){            // If Nack received                // Prep Stop Condition                   USISRL = 0x00;                   USICNT |=  0x01;            // Bit counter= 1, SCL high, SDA low                   I2C_State = 18;              // Go to generate Stop                   break;                 }                 // else                 P1OUT |= 0x01;                   // LED on: sequence start                 P1OUT &= ~0x01;                   // LED off: sequence start                 I2C_State = 6;              // Go to generate Stop                // no break, fall-through to case 6.       case 6: // Transmit Data to Slave 


Viewing all articles
Browse latest Browse all 232395

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>