19sept14 building a coffee pot simulation using...
Post on 10-Jul-2020
1 Views
Preview:
TRANSCRIPT
Building a COFFEE POT simulation on CCESS for Blackfin BF533
Introduction for Lab0 and Assignment 1CCES is based on Eclipse
There is an ARM IAR plug‐in for Eclipsewhich allows the same approach to occur
there
Step 1 ‐ 21. On your H: Drive build a directory
– ENCM511_2014Workspace2. In that directory, build sub‐
directories– uTTCOS– CoffeePot_Simulation2014
3. On Windows start menu ‐‐ click– ALL Programs | Analog Devices |
CrossCore Embedded Studio 1.0.3 | CrossCore Embedded Studio 1.0.3
– When asked “select a work space” select H:ENCM511_2014Workspace
Steps 3 on
3) Create a new project– FILE | NEW PROJECT– Use project name CoffeePot_2014Assignment1
4) Choose – Processor Family – Blackfin– Processor Type – ADSP‐BF533– Silicon revision – ANY(A301 has BF533 Silicon Ver. 0.6,A305 has BF533 Silicon Ver. 0.5)
Build a CCES project continued – 5 to 7
5) Click through to Template code screen
– Unclick ticked box ‐‐Add a default source file
– Click Finish6) Close CCES “welcome window”7) Click on little triangle next to the Project nameCoffeePot_2014Assignment
Add a src folder(Do same if
using Eclipse IAR MIPS plugin)8) Right click on CoffeePot_2014Assignment
– Select NEW |Folder • use folder name “src”
– MAGIC stuff associated with USE_CCES_GUI simulator (WAIL)
• Select NEW | Folder• Use folder name “SIMULATION_DATA”
(Capitals and underscore are critical)9) MAGIC – right click on system.svc file and OPEN
– Click on tab – Startup Code /LDF– WAIL ‐‐Will need this when we want to
“Add a simulated coffeepot to the address and data busses of the “real Blackfin processor.
LDF – loader descriptor file – describes where the LINKER places program code and program data in the microprocessor memory
Add “your” files to the project 10) Right click on “src” folder icon
• NEW | File from template • Filename CoffeePot_main .cpp
– Also add• MyCoffeePotFunctions.h• DoSimulation_CPP.cpp• DoSimulation_ASM.asm• MyCoffeePotFunctionsCPP.cpp
• All these files are currently empty and need to be filled
• Cut‐and‐paste from lecturepdf works (with a caution)
Risk management – Know what you don’t knowAre we using the correct ASM format?• Click on DoSimulation_ASM.asm icon to open the file inside the editor
• Add the information we had from previous presentation – see next slide (Cut‐and‐paste from pdf)
• Right click on DoSimulation_ASM.asm icon and select –Build Selected File(s)– Click on Console tab to see errors– Expect errors – should see them as markers against each line in editor
– Comment out all error lines– Build with no errors
ASM code entered in showing requiredcourse formatting (Before BUILD)
DO A CODE REVIEW
Something is DEFINITELY wrong here. There is a change of colour
Looks “sort of good” as is recognized – probably correct syntax
SyntaxError
Meansproblem at assemblerstageNOTlinkerstage
Look up “correct” assembly code syntax
• Use last year’s notes• Download BF533 manual
http://www.analog.com/en/processors‐dsp/blackfin/products/manuals/resources/index.html
– Link is available from ENCM511 website
Right Click on project NameBuild Project – results in “LINKER error”Linker wants to load functions into memory – but can’t find them
Understanding linker errors
• CCES can handle many processors or multi‐core systems.– This error message says the “processor p0” code is missing two functions– .doj extension indicates an object file – a file that has undergone the conversion
C++ asm almost machine code or asm almost machine code(performed by compiler and assembler) (performed by assembler)
– Many .doj files linked together form executable program .dxe that can be downloaded to the board (or run in the BF533 simulator)
– Function UpDateSimulationDisplay needed in file DoSimulation_ASM.doj (object file you wrote)
– Function main( ) needed in file app_startup.doj• This is an object file from a C++ / C / asm file you did not write, but was placed into your
project automatically when you made a project • Probably a system file that makes the C++ environment work – do not change or delete
Let’s add a main( ) to CoffeePot_main.cpp
• Before clicking “Build project”– Do a code review BEFORE compiling (PSP ‐‐ Personal Software Process)– Fix all syntax errors that editor is telling you about
The number of syntax not found after YOUR code review– indicates possible logical mistakes left behind in your code – not found by you or compiler
Build is improving Coding mistakes found before moving onto next
phase are called Coding ErrorsDesign mistakes found before moving onto next phase are called Design Errors.Design mistakes not found before moving onto next phrase are Design DefectsExpensive to fix as you don’t know where you made them
Too many things wrong with the .asm file – Let’s exclude it (DIFFERENT FROM remove it)
• Right click on .asm file – select properties
• Click on C++ Build• Click on Settings• Click on “Exclude resource from
build”• Click “OK”• Clean project (Recommended)• Rebuild Project
(F7)
Outside A301 / A305 run code in simulatorInside A301 / A305 run using emulator
• If built with no errors• Right click Project name
– Select Debug as | CrossCore application• In Select Processor window – chose Blackfin ADSP‐BF533 then NEXT
• In Select Connection type ‐‐ choose Simulator then FINISH. (Select Emulator in A301 or A305)
• In Create, Manage and Run window, select CoffeePot_.... Program, click APPLY, click DEBUG
• In CONFIRM Perspective Switch click No to switching to Debug display mode (I prefer C++ display mode)
Click green triangle in DEBUG tag to run (Also F5) See output in Console tagCheck HelloWorld ran correctly in Disassembly tag
Now add choice about doing simulation in C++ or ASM
These are C++ syntax errors associated with telling the compiler how to handle all these functions. ** Note compiler only wants “prototype” information –Not interested in code – just the interface (how to call)
Non‐printing character appeared when I cut and pasted the code
from slidesThere is
something wronghere
NOTE: .h file names have been changed‐‐ fix
Catastrophic error on buildCan you see what the problem is?
• Neither can I – Probably my fault somehow (always is)• In such cases, I look for name typos (none obvious), non‐printing characters (none)• Do a Project | Clean, then rebuild (in case editor confused) – did not help.• Apply “Botheration Level” test. It’s one line! Its faster to delete it and type in again
than worry about finding what caused the problem. – If it happens again – then spend the time to find out what you are doing wrong
Different errors from not having the code for simulator special features
WIDFI – Temp fix ‐‐ Add files with the “functions we are missing” generated as stubs
NOTE: file names have been changed since I generated the
display
After the build I saw that I have added the prototypes but not the function stubs
Explain errors in code pastedfrom last presentation
void TurnOnWater_CPP(COFFEEPOT_DEVICE *baseAddress, unsigned char waterInputLevel)
Use#warningon BF533
Use #messagein Visual CPP
Pragma #message (Visual C++)Pragma #warning (ADI CCES C++)PRAGMA – compiler specific C++ extension
Pseudo code for other functionsvoid PrepareTheCoffeePot_CPP (COFFEEPOT_DEVICE *baseAddress) { • Set the INITandSTAYPOWERED bit in control register• Update the simulator• In a loop
Update the simulatorCheck it CONTROL REGISTER DEVICE_READY bit is onExit the loop if on
}
void TurnOnHeater_CPP(COFFEEPOT_DEVICE *baseAddress, unsigned char heaterLevel) {Equivalent to TurnOnWater_CPP( ) function
– different part of COFFEEPOT structure}
Design DEFECT recognizedWe said // LED CONTROL (Bits 15 to 12) ‐‐W1S#define LED_CONTROL_OFFSET 12#define LED1 (1 << (LED_CONTROL_OFFSET + 0)) // 0x1 – LED 1#define LED2 (1 << (LED_CONTROL_OFFSET + 1)) // 0x2 – LED 2#define LED3 (1 << (LED_CONTROL_OFFSET + 2)) // 0x4 – LED 3#define LED4 (1 << (LED_CONTROL_OFFSET + 3)) // 0x8 – LED 4
Which requires the control register be “unsigned short int” – 16 bits
• But we saidunsigned char ReadControlRegister_CPP(COFFEEPOT_DEVICE *baseAddress );
Which makes the control register “unsigned char” – 8 bits
BIG QUIZ HINTDESIGN ERROR – Found when we made the mistake before moving onto next phase of projectDESIGN DEFECT ‐‐ Found the mistake at a much later phase of project – can be costly to fix
This design defect is easy to fix as we are not at a “too much later” phase in the project// LED CONTROL (Bits 7 to 4) ‐‐W1S#define LED_CONTROL_OFFSET 4
BUT LET’S NOT CHANGE unsigned char to unsigned int AND SEE WHAT WEIRD STUFF HAPPENSAND FIX IF THE WEIRD STUFF HAPPENS – As would happen if we made a defect in a real project
QUIZ AND LAB HINT – Can you predict what might happen if this design defect is not fixed?You might want to fix immediately to avoid spending time chasing down hidden errors
Lets build and run the project
Hover over coffeePot1_BaseAddress ‐‐ 0x0000000 ‐‐ we are using illegal base address
Enum issue (Editor problem)Also – system is complaining about COFFEEPOT1 – even though that is a defined enumin
MyCoffeePotFunctions.h
Temporary fix – make a copy of the enum declaration in main.cpp.Makes matters worse – complains of double define of enum
WAIL fix – enum only used in our main( ) at the moment – so only declare it there –comment out in MyCoffeePotFunctions.h with warning message so we know where to fix things global if this code decision comes back to haunt us.
Still crashes system when it is executed – but if hover the mouse over COFFEEPOT1 in the code window – shows as 1 after the crash so that can’t be the reason for the crash
Next step• Add the proper coffeepot simulator library to the project
• Add “simulated” coffee pots to the system
• Try out a “already built” coffeepot project using the 3 display modes– USE_TEXT_GUI, USE_CCES_GUI, USE_SPI_GUI– Can be bit‐wise OR‐ed to mix and get 2 displays
USE_TEXT_GUI | USE_CCES_GUI
top related