Jump to content
43oh

Button interrupt not working in CC430 with RF


Recommended Posts

Hi, I'm getting a weird problem with a button interrupt while using the RF1A module on a CC430F5137 chip, where the code inside the main loop only works 1 time and never again even though the ISR is being executing and flag (buttonPressed) are being set correctly. I can't find what's wrong and can't proceed to fix the problem.

 

Main.c

extern uint8_t buttonPressed;

uint8_t main(void) {
	WDTCTL = (uint16_t)(WDTPW | WDTHOLD);	/* Stop watch dog timer */

	__disable_interrupt();

	//ACLK = REFO 32768 Hz
	//MCLK = SMCLK = 12 MHz
	//UART 38400
	hal_init430();
	hal_initTimers(); //2Hz timer for alive-LED
	
	uint8_t i;
	for(i = 0; i < 4; i++) printf("Syncing UART\r\n\r\n"); //prep realTerm to display ascii characters 
	
	printf("Initializing RF core\r\n");
	phy_reset(); //set voltage levels, write rf registers, etc.
	phy_enableRX(); //go into RX mode
	printf("RF Core initialized\r\n");
	
	//main while loop
	while(1) {
		if(buttonPressed) {
			__no_operation(); //for debugging
			
			buttonPressed = 0;
			printf("\r\nButton pressed!		main-while-loop\r\n");
			phy_transmit((uint8_t*)TxBuffer, sizeof TxBuffer);
		}
		
		__bis_SR_register(LPM3_bits + GIE);
	}
	
	return 0;
}

isr.c 

extern uint8_t buttonPressed;		//hal.c

/*************************************************************************************
 * 				MSP430 Core Interrupts
 *************************************************************************************/
#pragma vector=PORT1_VECTOR
__interrupt void PORT1_ISR(void) {
	switch(__even_in_range(P1IV, 16))
	{
	case  0: break;
	case  2: break;                         // P1.0 IFG
	case  4: 		                        // P1.1 IFG
		P1IFG &= ~BIT1;
		__delay_cycles(24000);				// 2ms debounce delay
		
		//button is active low
		if((P1IN & BIT1) == 0x00) {
			//button is pressed down, transmit "Hello World"
			printf("\r\nButton is pressed 		Line 39 isr.c\r\n");
			buttonPressed = 1;
		}
		__bic_SR_register_on_exit(LPM3_bits); 	//Exit active
		break;
	case  6: break;                         // P1.2 IFG
	case  8: break;                         // P1.3 IFG
	case 10: break;                         // P1.4 IFG
	case 12: break;                         // P1.5 IFG
	case 14: break;                         // P1.6 IFG
	case 16:                                // P1.7 IFG         
		break;
	}
}

UART log for RF project




			
		
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...