Hello all,
A few questions about the SCTimer. I've read the cookbook but some details are unclear.
In my project I'm using the SCT on an LPC812. I'm using three states, 0,1 & 2.
In state 0 the LPC waits for a rising edge on the input, once it does it moves to state 1.
In state 1 the LPC waits for a timer to reach a particular value & once it does the output is driven high.
In state 2 the LPC waits for a falling edge on the input, once it does it should drive the output low & return to state 0.
As you can see the timer is only really used in state 1.
My questions are then:
1. Should the timer only be started & stopped in state 1, or should it be started once all events & states are defined & left running?
2. The states above should run sequentially i.e. 0 -> 1 -> 2 -> 0 etc. & individually, i.e. the state 0 & state 2 actions should not occur at the same time. Does this happen by default on the perhieral or does it need to be implemented by the programmer?
Many thanks,
Sabina,
Thanks for the reply.
1. I found that unless the command SCTIMER_StartTimer was issued no events (including I/O events) were responded to by the SCT. I imagine it appears obvious to anyone with experience of the peripheral.
2. Also it appears that SCTIMER_ScheduleEvent command must issued for each event to have an impact in each state, so by default they are separate.
Hello,
If you would like further reference examples. You can download the SDK for the LPCXpresso812MAX which is one of our evaluation boards that use the same microcontroller you are working with.
Once downloaded, you can open the demo examples in the MCUxpresso IDE.
Here are the one included for SCTimer:
If you have further questions, let me know!
Sabina
Hello,
To answer your questions:
1. Simply, this is up to you as the developer of your application. In order to determine when to start and stop the timer, think about what the purpose of the value will be for. If it is important to time how long the state lasts, then the start and stop will be within state 1. However, this depends on the final goal of the timer.
2. If using a state machine, these should be separate and defined as so. Assuming that you are using the same input pin to detect either a rising edge or a falling edge, this configuration will need to be reinitialized when you enter each state. If this is not done then the interrupt will be caused by the previous configuration.
Please let me know if this answers your questions.
Best Regards,
Sabina