This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/MSP432P401R: recoding time on MSP432P401R

Part Number: MSP432P401R


Tool/software: Code Composer Studio

Dear all,

I notice that after we initiate the SysTick, when we implement SysTick_getvalue() it will return the count value instead of the time value. I am trying to find a way to convert the count value to the time value right now because my team's design requires the clock runs 36MHz, which means the clock will tick every 27.78ns. Let's say if I create an integer named count, and then every time the clock ticks, the count will be increased by 1. For instance, when the clock ticks 300 times (equivalent to 8.334us), my count value will become 300?  I also want to use a GPIO as an input, and every time the input is high I can append the current count value into an empty vector. Then after 2.65ms (count=95392), the input will be disabled, and no matter if the input is high or not, the whole operation will be called off.

Now I only have a rough idea of how to do it:
/* start of the code*/

int count=0;

int main (void){

MAP_WDT_A_holdTimer();

MAP_GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P1, GPIO_PIN1);

MAP_GPIO_interruptEdgeSelect(PIO_PORT_P1, GPIO_PIN1, GPIO_HIGH_TO_LOW_TRANSITION);

MAP_GPIO_clearInterruptFlag(GPIO_PORT_P1, GPIO_PIN1);

MAP_FPU_enableModule();

MAP_CS_setDCOFrequency(36000000);

MAP_PCM_setCoreVoltageLevel(PCM_VCORE1);
MAP_FlashCtl_setWaitState(FLASH_BANK0, 1);
MAP_FlashCtl_setWaitState(FLASH_BANK1, 1);

MAP_SysTick_enableModule();
MAP_SysTick_setPeriod(1);
MAP_SysTick_enableInterrupt();

MAP_Interrupt_enableMaster();

while (count<=95392)
{
if (/*PIN1.1 high*/){

/*array append current count value*/

}
}

}

Void SysTick_Handler(void){

count++;

}

Is it a good approach? I do not want to just attempt it on the board since I have made so many mistakes on running the clock with high frequency and the MCUs were just bricked, and I had to purchase another one.

  • Hi Keith,

    It looks like you are on the right track counting the sys_tick. 

    Controlling when you update the array with a count value won't work you are suggesting.

    Can you see the problem?  In the while() loop if P1.1 goes high you record the sys_tick value.  As long as P1.1 remains high you keep appending the sys_tick value to the array.  I assume you only want to record the sys_tick value as P1.1 transitions from 0 -> 1.  In this case use a flag to indicate when it is appropriate to write to the array. For example:

    bool flag = false;

    while()

    {

    if ( (P1IN & BIT1) && (flag == false) )
    {
          write sys_tick;
          flag = true;
    }
    else if (!(P1IN & BIT1))
         flag = false;
    }

    Not sure why/how you were able to "brick" the MCU?

  • It was on this thread:

  • Hi Keith Xia,

    I see in the other posting (thanks Keith Barkley) that the device you were using was possibly a pre-production sample and you saw a message such as:

    "Your XMS432P401R material is no longer supported. We recommend you moving to production-quality MSP432P401R/M silicon"

    If you indeed had an XMS version, it's quite possible you "bricked" it.

    You should be good with a newer launchpad which will have factory tested and passed silicon.  Let me know if you have any issues.

  • Us Keiths have to stick together. 8^)

  • Cool - there is power in numbers ;)

    Keith Xia,

    I'll assume this addresses your issue and you are able to move forward with your project.
    If this isn’t the case, please click the "This did NOT resolve my issue" button and reply to this thread with more information.
    If this thread locks, please click the "Ask a related question" button and in the new thread describe the current status of your issue and any additional details you may have to assist us in helping to solve your issues.

    Thanks again Keith B - your help in greatly appreciated.