Hi and hello!
I seem to never get out from these functions, and at this point I've tried everything (i know of) so i'm just gonna put everything on the table. I get no compilation errors or warnings and the rest of the code runs fine. I'm using the latest gcc compiler and i'm flashing the processor with Flasher.exe from the command line with "MSP430Flasher.exe -n msp430g2xx3 -w "main.hex" -v -z [VCC] -m SBW2" (i've also tried putting "-std=c99" at the end of it, with same results).
The full code is here: https://github.com/klaslofstedt/Zigbee_router_relay
Hope you can help me!
#include <msp430g2553.h> #include <stdint.h> enum Status { IDLE, READY }; volatile enum Status g_status = IDLE; #pragma vector=USCIAB0RX_VECTOR __interrupt void USCI0RX_ISR(void) { if(g_status == IDLE){ g_status = READY; } } void do_this1() { unsigned int ms = 500; while(ms > 1){ P1OUT = (BIT6); // this happens __no_operation(); P1OUT |= (BIT0); // this happens ms--; } } void do_this2() { unsigned int ms = 500; while(ms > 1){ P1OUT = (BIT6); // this happens __no_operation(); ms--; } P1OUT |= (BIT0); // this is not happening } void do_this3() { P1OUT = (BIT6); // this happens __delay_cycles(950); P1OUT |= (BIT0); // this happens, however i don't know if there is an actual delay } void do_this4() { P1OUT = (BIT6); // this happens __delay_cycles(990); P1OUT |= (BIT0); // this is not happening } int main(void) { // stop watchdog WDTCTL = WDTPW | WDTHOLD; // 1 MHz DCOCTL = 0; BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; // init leds P1DIR = (BIT0 | BIT6); P1OUT =~ (BIT0 | BIT6); // enable UART + interrupt P1SEL = (BIT1 | BIT2); P1SEL2 = (BIT1 | BIT2); UCA0CTL1 = UCSWRST; UCA0CTL1 |= UCSSEL_2; // SMCLK UCA0BR0 = 104; // 1MHz 9600 UCA0BR1 = 0; // 1MHz 9600 UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1 UCA0CTL1 &= ~UCSWRST; IE2 |= UCA0RXIE; //Enable USCI_A0 RX interrupt __bis_SR_register(GIE); for(;;) { if(g_status == READY){ // Comment away three of them so only one run at the time do_this1(); do_this2(); do_this3(); do_this4(); g_status = IDLE; } } }