Contents:
When you start CamelStudio, you see a screen as the following:
To creating a new project:
Select Project -> New Project
In the window that pops up, give the new project an appropriate name, for example Project1, the file extension is *.cms.
Click the Browse button and select an empty folder to save your project.
At the left bottom of the dialogue, select the technology for your application.
Click the OK button. This opens an empty file displayed in the project window.
The syntax for the cms project file is equation liked: on the left side of the "=" is the keyword of the .cms file; on the right side of the "=" is the corresponding content of the keyword.
KEYWORD
In the project file, the keywords after a double-slash comment are the files your project may include. You can type the full path of the source file or just the name of the source file if these files and the project file are under the same directory.
Using the menu:
Project -> Open Project
In the window pops up, navigate to your memory stick and select the project file you want to open. Click Open
To saving the project:
Select Project -> Project
To build an application, CMStudio provides two build options:
Click Build or Build Debug to compile all source files. The Application Output window displays errors, warnings, and build messages during the build process.
If AUTOLOAD keyword is set to true in the project file, once the code build successfully, CMStudio attempts to load the compiled binary file into MCU automatically as long as the connection between PC and testing board established. It spends some time loading the application. When CMstudio has finished loading, you see a message at the last line "load *** line code to ***".
CMStudio provide a Serial Port Window for UART communication with the mcu.
Click the Configure button, a Settings dialogue pops up allows setting the communication COM port, the baudrate and other parameters of the system.
Click the Apply button to make connection. You can see a message indicates the serial port status as following:
The command window CMD at the bottom of the view is used for communicating with the mcu. The commands you typed into CMD are transmitted to the mcu.
SUPPORTED COMMAND FORMAT
"write 10000000 1" means "write 0x1 to address 0x10000000"
"write 10000000 1 2 3" means "write 0x1 to address 0x10000000 write 0x2 to address 0x10000004, write 0x3 to address 0x10000008"
"read 10000000 n" means "read data from n consecutive address start at 0x10000000"
"load 10000000 < filename > means "load < filename >" to address 0x10000000", you can also load the filename to MCU using "UART load" under "Tool".
UART Communication Example
Write word
After the connection established, type "write 10000000 9" with the Enter Key in the CMD window. This action write "9" to address 0x10000000:
Read word
Type "read 10000000 1" with the Enter key in the CMD window to read the value in 0x10000000 in the mcu. The value you want to read displays in the Application Output window.
CMStudio supports hardware debug for your program. After the connection between CMstudio and board being successfully established, you need to use Build Debug to build your application.
The debugger from CMStudio includes features like breakpoints, watch windows and execution control.
Debug Views
CMStudio offers different views into the source code and data comprise your application including code editor, core registers view, peripheral registers view, SRAM view, Flash view and serial port view.
Code Editor
CMStudio integrated a code editor to review the source code. Click File -> Open.
Navigate to the location where your source file stored, select the file and click Open.
Editor appears on the screen.
When you want to save the modified file, click File -> Save or if more than one file needs to be saved, click File -> Save All.
Variable View
The Variables window shows the current value of the variables.
Where
Address: displays the memory address of the item.
Variable Name: displays the variable name
Value display: the value of the item.
Core Registers View
The Core Register window displays the core register area content.
Where
Address displays: the memory address of the core registers.
Register Name: displays the name of the core register.
Value: display the value in the register.
Module Registers View
The Module Register window displays the module register area content.
Where
Address: displays the memory address of the Module registers.
Register Name: displays the name of the Module register.
Value: display the value in the register.
SRAM View
The SRAM window displays the SRAM area content.
Where
Address: enter an expression that evaluates to a memory address.
Count: enter number for n consecutive address start at the address you input.
Value: display the value in the item.
Flash View
The Flash window displays the SRAM area content.
Where
Address: enter an expression that evaluates to a memory address.
Count: enter number for n consecutive address start at the address you input.
Value: display the value in the item.
Breakpoints
Before debugging a program, you should set breakpoints in your debug file. CMStudio currently allows up to two breakpoints during hardware debugging. You can use both GUI or command line to add breakpoint. A red dot indicates the breakpoint.
Using GUI:
Right click the mouse while it is pointed to the line number on the gray bar to the left of the edit window. Select set breakpoint to put a breakpoint.
Using Debug Command:
The Application Output window shows generic debug ouput information and allows entering debug commands in CMD window to interact with the program.
Set breakpoints
"b 40" means " set a breakpoint at line 40 of the current active file".
Show breakpoints
"info b" will show you all the breakpoints you set so far.
Disable breakpoint
"dis 2" means " disable the breakpoint with id of 2".
Enable breakpoint
"dis 2" means " disable the breakpoint with id of 2".
Delete breakpoint
"dis 2" means " disable the breakpoint with id of 2".
Start Debugging
Start debugging using the menu Debug -> Start Debugging(or
), the debugger starts and program pauses at the breakpoint you set.
Continue
when you select the menuDebug -> Continue(or
), the debugger resumes the execution and stopped at the next breakpoint.
Step Over
when you select the menuDebug -> Step Over(or
), the debugger executes one line of the program.
Step in
when you select the menuDebug -> Step in(
), the debugger traces inside function calls.
Step Out
when you select the menuDebug -> Step in(
), the debugger exit the function calls.
Stop Debugging
when you select the menuDebug -> Stop Debugging(
), the debugging session terminated.
Board Setup
Burn FPGA bitfile to the board, when finished, the LED should display "1111 1111".
Open Project file
The demo project file is called demo.cms. Open the project via the menu Project -> Open Project and select the file demo.cms from the folder …\CamelStudioRelease\demo
Connecting Serial Port
Under the serial port window, click the Configure button. In the dialogue pops up, give the appropriate COM port number and BaudRate. Then click the Apply button.
Click Connect to make connection.
Build Application
For debug lately, build the application using the menu Project -> Build Debug, the Application Output window displays progress messages.
Load Application
Since the AUTOLOAD keyword is set to true, CMStudio load the application automatically when built complete. The last line of the build information shows in the window indicates the code is successfully loaded into the location you set.
Switch to usr Mode
Once the code is loaded to FPGA, you need to turn on the U8 switch (the second swatch from the right bottom on the board) and push the reset button which make the studio to run the program starting from the address 0x10000000. The LED should display inverted "AAAA A", you can see a hello message in the serial port window as well.
Debugging
Open the file you want to debug: using File -> Open File. Select main.c under your demo project directory.
Set breakpoints: you can add two breakpoints on line 45 and 60 for example easily by right clicking the mouse while it points to line 45 and 60 and select set breakpoint in the pop up menu.
Check breakpoints: the command info b shows you all the breakpoints you set so far along with their status.
Start debugging: start debugging using the menu Debug -> Start debugging (or
). From the serial port window, you can see the execution of the program is suspended at the first breakpoint you set.
Continue: click Debug -> Continue (or
), the debugger resumes the execution and stop at the second breakpoint.
Step over: click Debug -> Step Over(or
), the debugger step to the next statement.
Step In: when program execute just before a call function findmood(), click Debug -> Step In(or
)), the debugger traces inside the function.
Step Out: After the walking through the called function , click Debug -> Step Out(or
)), the debugger resume to execute the next statement in the main function.
Stop debugging: click Debug -> Stop Debugging(or
)), debugging session terminated.
To start another debugging session, you need to remove all the breakpoints and push the reset button.
Check value: When the program stopped at the breakpoint, you can use "Variables window", "Core Register window", "Module Register window", "SRAM window" and "Flash window" under “window” to check the values at those places. you need to use “refresh” button at the bottom of the window to see the updated value.
Check value: you can also use the CMD window to print out the value you want to check.
"p a" will print out the value of variable "a" in decimal format
"p /b a" will print out the value of variable "a" in binary format
"p /x a" will print out the value of variable "a" in hex format
"p 0x......." will print out the value stored at memory location 0x......
To execute the whole program, you should delete the breakpoint you have set before, and then disconnect the FPGA board with CMstudio by click Disconnect button under the serial port window. After that, push the reset button to make everything clear and then reconnect the board with the CMstudio. You can run the program using the menu Project -> Run.