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.
Part Number: MSP432P401R
Hello,
I want to implement a delay function.
From the SDK, I couldn't get any examples for Delay usage.
Can someone share, any examples or any APis to use for the same purpose. Like having a delay of 1ms or 5ms delay in code.
Hi Tajpeer,
would the intrinsic function "__delay_cycles(10);" help you here.
I have seen this API. But couldn't get the implementation details for it.
And also I have one function which actually requires actually a delay of ~2ms to function as expected. But using this it's not happening.
And moreover, is this API depends on any parameters like clock?
Let me know the exact details. Like setting the clock and passing values to this API's etc
Hi
its not an API it's a low level macro and yes it depends on frequency.
Finally it is nothing else than executing 1 cycle instruction (nop) in a loop means if you run a 1 MHz CPU clock the delay would be for 100 cycles ~100us.
If you want to have a more accurate one you have to use a TimerA and configure it to compare mode and select the count value in relation to the selected clock frequency. If you do this in low power mode and wake-up via interrupt it would safe power too
Hope this helps.
I use SysTick to implement an arduino-like millis function The LED toggle is an optional blinky-light. Of course, Millis must be volatile.
void SysTick_Handler(void) { Millis++; if (Millis%10000 == 0) { // Every 10 seconds MAP_GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0); } } void Delay(int msec) { // Busy wait msec ms int starttime = Millis; while((Millis - starttime) < msec); }
Oh, here is how I set up SysTick:
// Configure SysTick MAP_SysTick_enableModule(); // 48M = 1 sec, 4.8M = 100ms, 480000 = 10ms... MAP_SysTick_setPeriod(48000); // Every 1 msec MAP_SysTick_enableInterrupt();
This thread will be closed due to inactivity since 2 weeks. If anything pops up pls open a new thread.
**Attention** This is a public forum