Quantcast
Channel: MSP low-power microcontroller forum - Recent Threads
Viewing all articles
Browse latest Browse all 21949

MSP432P401R: MSP432P401R

$
0
0

Part Number:MSP432P401R

I have written a program to measure analog value at P5.4 using a timer as the measuring interval. The code works fine. When i remove the while loop and run the code in CCS v7 the code exits after one round of raising interrupt and measuring. But in debug mode when i keep my break point inside the interrupt the program goes into exit routine after the first time of interrupt. But if i continue giving resume both the timer module and adc works fine.

According to rules the program must terminate if there is no locking loop in the main function. Why is the interrupt being called  even after going through exit routine in debug mode. 

#include "msp.h"
#include<stdio.h>

int main(void) {
    volatile unsigned int i;
    __enable_irq();
    NVIC->ISER[0] = 1 << ((T32_INT1_IRQn) & 31);
    WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD;     // Stop WDT

    // GPIO Setup
    P1->OUT &= ~BIT0;                       // Clear LED to start
    P1->DIR |= BIT0;                        // Set P1.0/LED to output
    P5->SEL1 |= BIT4;                       // Configure P5.4 for ADC
    P5->SEL0 |= BIT4;

    //TIMER32_1->CONTROL = BIT6 | BIT5| BIT1 ;
    TIMER32_1->CONTROL = TIMER32_CONTROL_SIZE | TIMER32_CONTROL_MODE;
    TIMER32_1->LOAD= 0x0026CDC0;
    
    ADC14->CTL0 = ADC14_CTL0_ON |
                ADC14_CTL0_MSC |
                ADC14_CTL0_SHT0__16 |
                ADC14_CTL0_SHP |
                ADC14_CTL0_CONSEQ_1;

    ADC14->CTL1 = ADC14_CTL1_RES_2;

    ADC14->CTL0 |= 0x00080000 |0x00100000;
    // Disable sleep on exit from ISR
    SCB->SCR &= ~SCB_SCR_SLEEPONEXIT_Msk;
    //SCB->SCR |= SCB_SCR_SLEEPONEXIT_Msk;

    TIMER32_1->CONTROL |= TIMER32_CONTROL_ENABLE | TIMER32_CONTROL_IE;
    ADC14->MCTL[0] = ADC14_MCTLN_INCH_1;
    ADC14->CTL0 |= ADC14_CTL0_ENC | ADC14_CTL0_SC;
    SCB->SCR |= BIT2;

//    while(1){
//
//    }
}

void T32_INT1_IRQHandler(void){

    TIMER32_1->INTCLR |= BIT0;              // Clear Timer32 interrupt flag

    if (ADC14->MEM[0] >= 0x7FF){             // ADC12MEM0 = A1 > 0.5AVcc?
        printf("less\n");
        P1->OUT |= BIT0;                      // P1.0 = 1
    }

    else{
        P1->OUT &= ~BIT0;
        printf("more\n");
    }
//    P1->OUT ^= BIT0;
}


Viewing all articles
Browse latest Browse all 21949

Trending Articles



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