Overview
In the course of considering the application of A tiny MML parser, I noticed that LPC 810 was sleeping at hand. A tiny MML parser with 8 pin ARM Cortex – M 0 + is wonderful.
As soon as I looked it up, when considering making it work like Arduino the other day, I found out that it would be better to configure PWM using State Configurable Timer (SCT).
Although it is SCT which is greatly unpopular here and there, I thought that it could actually be used easily.
However, after actually trying, it was a big sinking. Even if you read the register map and function description, you do not understand the meaning at all what way you want it if you set it what you want.
Meanwhile, I found an ex size to let the LED flash on the state machine, so I decided to try it from the head. It can be applied to PWM which only toggle output by applying this.
resource
Exe size resources : http://www.nxp-lpc.com/updated_materials/sct/lpc81x/LPC81x_SCT_code_examples.zip
Exercise presentation : https://onedrive.live.com/view.aspx?resid=7AE40E5A5F1EC907!24470&ithint=file%2cpptx&app=PowerPoint&authkey=!ACDxmgRtdAZZdXE (From slide 30 pages)
Exe size resource
The downloaded exe size resource is the contents at the time of starting work in order to actually finish the project according to the explanation. Set up the project and open the slide 30 page.
Red State Machine file generator
Press the “Choose Target” button to select the target.
The above preparation is completed.
It is the start of exe size.
Step 1
- Delete U_ALWAYS state
- Configure the state on the State Table tab
Next, enter the two states on the State Table tab that manages the state.
If you enter a state name or the next state name in this State Table, it will automatically be reflected in the state editing GUI at the center of the screen.
The screen immediately after editing is as follows.
Please drag and move the box showing the state with mouse with a slight arrangement because it is dirty.
Arrows may look bidirectional, but that’s not the case.
Please place it so that it looks like two.
Step 2
Next we define the input to the state machine, delay and match 0.
Step 3
Add a definition of behavior.
EVENT 0
First, press the plus button at the top right of the Action List tab to add a new action and change the name to EVENT 0.
Define the behavior for EVENT 0.
To do this, move the cursor over the table labeled Operation and right click to do it.
Select “Output pin 0” for the Set operation.
Select “Limit unified counter” for the Call operation.
EVENT 1
Define EVENT 1 in the same way.
Change the name to EVENT 1 and add the following actions.
EVENT 1 selects the reverse operation Clear Output pin 0 for EVENT 0.
As with EVENT 0, add Call Limit unified counter as well.
Step 4
Once we have defined the behavior, we associate it with the state.
Return to the State Table tab and click the Action column to select the event you defined earlier.
When it is completed it will be as follows.
Just to be sure, let’s check the contents of the Signals tab here.
This value is added automatically when the Signal name is first inserted in the State Table.
At this point, the state machine editing screen in the center of the screen is as follows.
Step 5
Open the Outputs for State Machine tab and set the preload value.
Press the Generate Code button to generate the code.
Step 6
Switch workspace and enable SCT initialization code.
Remove the commented out of the commented out place which was implemented beforehand with the exe size code.
Next, open sct_user.h.
The exhaled code implements the definition “#include” board.h “”.
Rewrite it here as “#include” LPC8xx.h “”. There is this definition file in CMSIS enclosed in this exe size.
Why this kind of work is required is that sct_fsm.h is referenced from sct_fsm.c which the tool automatically generated, because the internal implementation of this sct_fsm uses the definition LPC_SCT.
The above file name can be preset for Header in sct_user.h of State Machine Settings.
Step 7
It is final adjustment.
First, decide the pin to be controlled by the SCT.
Let’s blink the LED of the LPC 800 Mini board this time.
This board has an LED connected to PIO 0 _ 2.
Set the SWM pin assignment register.
Bit 31:24 of the SWM PINASSIGN 6 register is the selection register of CTOUT_ 0.
Select output by adding values in order of 0x00 for PIO0_0 and 0x11 for PIO0_17.
Since it is PIO 0 _ 2 this time, it will be OK to set 0 x 02.
That’s all there is to it.
Other notes
CMSIS Clock Selection
The clock selection of CMSIS is included in the implementation side of system_LPC 8 xx.c.
It must be set according to the board to be operated.
If you make a mistake in this choice, you get confused with “Why does not it work?”
Target processor
Correctly select the target processor.
This setting is included in the properties of the project.
This choice changes the linker script given to the tool chain.