XPad 4-Step Tutorial
Want to know how easy it is to create Embedded Software with XPad?
Keep on reading!
|
|
Step 1: Start a new project with the Atmel AT89C2051
Start the wizard by pressing
Select "Start a new project" and press "Next".
Enter project-name when prompted. (I.e. "4Step").
Answer "Yes" when asked if you want to select an MCU yourself.
In the "Select Target" browser select "at89cx051.trg" for the Atmel AT89C2051 and press the "Load" button.
The wizard now allows you to select the interfaces/protocols you want to setup for this microcontroller.
Check the "Serial RS232" box and press "Next" to setup the serial port. (See figure on the right).
The hardware configuration panel pops up (notice the serial port on P3.0 and P3.1).
Make sure the frequency set on this panel is 24mHz (24.0E+6) and press the "Set" button.
|
![]() Hardware configuration wizard for Atmel AT89CX051
![]() Hardware configuration panel for Atmel AT89CX051
|
Step 2: Finish the State Diagram.
Select "STD: MAIN" from the "Windows" menu to bring the STD diagram to the front.
Press the "New State" button
Enter RECEIVE as the name of the new State.
To create a transition from the IDLE to the RECEIVE state, first click the IDLE state (it will get a green border) and next click the RECEIVE state (it will get a red border).
Now click transition button
In the Transition-popup box select the "Serial" condition in the ringlist at the top and press the Set-button.
|
![]() The resulting State Diagrams will first execute the flow diagram in the IDLE-state and
will then repeatedly execute the flow diagram in the RECEIVE-state,
whenever the Serial interrupt occurs.
Deselect the IDLE-state (click it again once; the green border will disappear).
Press the transition-button in the toolbar again to create a transition from the RECEIVE-state to itself. Select "Serial" again in the popup and press the Set button.
|
Step 3: Finish the Flow diagrams in the states.
Double click the IDLE state in the state diagram. (The flow diagram of the state will open). Double click the yellow enter-block to edit it.
Right click the yellow area and select "Insert After" from the popup -menu. (A function editor will popup).
Select "Serial Lib" from the library ring-list. Now select the "SER_Setup" function
if it is not selected yet.
Fill in the parameters for this function as shown on the right and press the Set-button. This finished the work for the IDLE state's flow diagram.
Now right-click the "Data Browser" and select "New Variable" from the popup-menu.
Change the name in the Variable Editor into "Char". Make sure the type is set to BYTE and press OK.
|
The Data browser will show the new variable under the "User Vars" section. (Double Click the "+" to open the "User Vars" section). This variable will be used to store characters received from the serial port and send them back.
![]() Single block of flow diagram for IDLE-state.
Select "STD: MAIN" from the "Windows" menu to bring the STD diagram to the front again.
Double click the RECEIVE state in the state diagram. (The flow diagram of the state
will open). Double click the yellow enter-block to edit it (It will enlarge).
Right click the yellow area and select "Insert After" from the popup -menu.
(A function editor will popup).
Select "Serial Lib" from the library ring-list and the "SER_Get_char".
Fill in the parameters for this function as shown below.
![]() Single block of flow diagram for RECEIVE-state.
Right-click this new function in the yellow block and select "Insert After" again.
This time select the "SER_Put_char" function from the "Serial Lib".
Fill in the parameters for this function as shown above.
In this example the flow diagrams are just single function-blocks, since no if-then or loop-constructions are required, which connect several function-blocks.
|
Step 4: Save, Simulate, Compile and enjoy your work!
Press the "Save" button
To simulate your project press the "Simulate" button
Press the "Step" button to step through the model.
When "RT transition evaluated..." is reported in the console, the model is waiting for a realtime transition (interrupt) to occur.
Since the model waits for the "Serial" interrupt to signal received characters, select "Serial" from the Interrupt ringlist in the bottom-left corner of the trace-panel and check the "On" box to charge it.
Now when you continue Stepping, the model will proceed to the RECEIVE state. The received character -set on the right from the RX-pin trace- is read and send back over the TX-pin.
|
![]() Simulation trace-panel.
Once you are satisfied with the simulation you can press the build-button
Your project-folder will now contain a bin-file, which you can program/burn straight into the AT89C2051!
|
XPad's distribution package contains many more examples for several MCUs, including:
|
|
Check out the FAQ page...
Take a closer look at some of XPad's screens and diagrams...
|
|