Part Number: MSP-EXP430G2
Hello, I have a question when coding ISRs.
#include <stdint.h> #include <msp430.h> // button interrupt #pragma vector = PORT1_VECTOR; __interrupt void Port1_ISR(void){ sw_debouncing(); do_something_when_debounced(); button_ifg_clear(); } // ADC10 interrupt service routine #pragma vector=ADC10_VECTOR __interrupt void ADC10_ISR(void) { uint8_t buffer[2]; uint16_t data = ADC10MEM; buffer[0] = (uint8_t) ((data & 0xFF00) >> 8); buffer[1] = (uint8_t) (data & 0x00FF); uart_tx(buffer, 2); }
I am sampling a signal with a sampling frequency 5000 Hz. When I sample the ADC data, I want to send it as 2 bytes using the UART (baud rate 115200, no parity, no flow control).
The UART sending part is working. However, I noticed that my button interrupt is not triggering.
I tested this by disabling the UART and the ADC to check whether this triggers or not.
If I disable both, the Port1 ISR triggers correctly.
I think the Port1 ISR doesn't get triggered because the UART sending (uart_tx) takes long inside the ADC ISR and when the code is inside the ADC ISR, it disables the global interrupt, doesn't it?
So my question is,
- Is there an option to enable the interrupt when the code is running the ISR?
- In this case, should I seperate the UART sending part from the ADC ISR and put it inside the main loop?
I let the MSP430 to go to sleep (Low Power Mode 0). So I'm also looking for an option to wake-up the MSP430 when the code is running inside the ISR.