Essential Of Lab0

Sections 1 and 3 on September 23rd
Sections 2 and 4 on September 30th
• A301 – All stations (1 – 16) have Blackfin BF533 boards
• A305 – Stations 1 – 8 have Blackfin BF533 boards
• A305 – Stations 9 – 16 have ENCM515 SHARC boards –
but also have Blackfin BF533 simulators
• Find a partner and form a group (Maximum 2 per group) – Okay for sections 1 and 3 to mix (ditto 2 and 4)
• Check the equipment – Find and turn on Blackfin System – LEDs on interface should blink
• Follow steps from last lecture to set up H:ENCM515_Workspace directory and Build a Hello World program inside you Assignment1 directory
Essentials of Lab0
Introduction for Lab0 and Assignment 1
CCES is based on Eclipse
There is an ARM IAR plug‐in for Eclipse
which allows the same approach to occur there
Finally ‐‐ Add a Hello World from Blackfin “main.cpp”
Compile, load and run on REAL Blackfin not simulator See other lecture notes for details
HINT: I have used UCEE special funds for 2 terminals per station.
Lecture notes on left screen
Lab 0 / Assigment on right screen
On Windows start menu ‐‐ click
–
ALL Programs | Analog Devices | CrossCore
Embedded Studio 1.0.3 | CrossCore Embedded Studio 1.0.3
Finally ‐‐ Add a Hello World from Blackfin “main.cpp”
Compile, load and run on REAL Blackfin not simulator •
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
• 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 tag
Check HelloWorld ran correctly in Disassembly tag
Let’s run a COFFEEPOT simulation on the real BF533 board (or simulator)
• Build an empty project –
ShowSimulation
– Remember to add the SIMULATION_DATA folder
– Close CCES
• From Windows – Download CoffeePotDemo.dxe
from ENCM511 Lab0 web‐page
– Place in ShowSimulation/Debug directory
– Reactivate CCES and check that .dxe is found in ShowSimulation/Debug directory
Not the cleanest way to run a standalone .dxe (but it works)
• Right click on “ShowSimulation” and Select “debug as Cross Core application”
• CCES will try to build – and complain it can’t find a main
• It will find the existing .dxe in the Debug directory and load that – which, by accident, is what you want.
– Note – this is an Eclipse issue rather than a specific CCES issue
• Select COFFEEPOT | Coffee pot viewer to activate (show) the CCES_GUI Coffeepot • Set the CCES focus onto the ShowSimulation project (Click on project name) and type F5 to run the simulation. – Each coffeepot should fill, and then blow up because of miscoding
– If the coffeepot GUI seems to stop running, check the focus.
The results I got.
I forgot to do a CODE REVIEW
Next Step towards
“You code up the COFFEEPOT operation”
• Download CoffeePot_SimulatorLibrary.dlb
from the ENCM511/Lab0 webpage into directory
H:ENCM511_Workspace2014/Cof
feepot.SystemFiles
• Go to your CCES project CoffeePot_2014Assignment1 and click Properties.
• Click C/C++ Build | Settings
• Click CrossCore Blackfin Linker | General
Incrementally add (enough) code to your CoffeePot_main.cpp source file
Standard Eclipse procedure
In section Additional Libraries
• Click the + (ADD)
• Select FILESYSTEM
• Find CoffeePot_SimulatorLibrary.dlb (just added) then OPEN then OK then APPLY then OK
Next steps
• Add more code to main( ) – CODE REVIEW, build run
• Do CODE REVIEW
• Build and run (remember to pop‐up Coffeepot GUI and set focus)
• Now you will need to start adding code to your DoSimulation_CPP.cpp file to stop build failing
You will get this error message
as “No coffeepot has been plugged in”
To add coffeepot to simulator.
• Right click “system.svc”, select OPEN
• Click on tab – Startup Code / LDF then LDF
This code requires you add
PrepareTheCoffeePot_CPP( ) code
to your MyCoffeePotFunctions.cpp and .h files
We simulate “adding a coffeepot”
By adding “Heap Memory” to system
• There are other ways of simulating “Add a coffeepot”. But I wanted to introduce you to the “Add a Heap” approach
• Do “Control‐S” to save the LDF (loader descriptor file)
• Rebuild and your project should run
If you don’t like my COFFEEPOT simulator – then build a racing car simulator. I will provide
the graphics library if your are interested (and have no other courses to do)
The control register has many fields
(parts that do different things)
Details shown in documentation as follows
Similar format in Blackfin manual for the registers used to control ‘on‐chip’ peripherals
COFFEEPOT PERIPHERAL ‐‐ OFFSET 0x00 – RESET 0x00
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
• I decide to have PrepareTheCoffePot_CPP( ) code both “initialize” the coffeepot (bit in control register write) and
“wait till coffee pot ready” (bit in control register read)
LED CONTROL (Bits 15 to 12) 0x1 – LED 1
0x2 – LED 2
0x4 – LED 3
0x8 – LED 4
Can combine values in a field
0x5 causes LED1 and 3 to be on
GENERAL CONTOL (Bits 4 to 0)
0x1 – b00001 ‐ Cause device to initialize (2 seconds) and stay powered up
0x2 – b00010 ‐ Turns LED Power on
0x4 – b00100 ‐ Turns Water control power on
0x8 – b01000 ‐ Turns Heater power on
0x10 –b10000 ‐ Device is ready after initialization ‐‐ RO (read only)
Can combine values in a field
0x6 (b00110) turns on BOTH LED and water power
but deactivates the device (bit 0 = 0; so nothing works)
NOTE: Design changes occurring – LED register now “a field” of the control register
16
NOTE: Design DEFECT introduced – We never fixed that old Control register was only 8 bits. Finish off C++ version of
filling‐and‐heat coffeepot water
Then add the code for TurnOnWater_CPP( )
Get that working BEFORE you add TurnOnHeater_CPP( ) code
• This code actually lets me switch between
TurnOnWater_CPP( ) and TurnOnWaterASM( )
• Share the coding between your and your partner
– Pair programming – One code the other review for a while – Then the other code and the first review
•
•
You need to look for, and use, the code samples in the lecture notes to do the following
Add 1 Coffeepot – and share the work in generating the code to fill the pot to 95% and heat
coffeePot1_BaseAddress = Add_CoffeePotToSystem_PlugAndPlay(COFFEEPOT1, "WDS");
•
Add 2nd Coffeepot – you do the work to fill this pot WITHOUT copying the work from the first coffeepot
coffeePot2_BaseAddress = Add_CoffeePotToSystem_PlugAndPlay(COFFEEPOT2, “Your name");
•
Add 3rd Coffepeot – your partner does the work to fill this pot WITHOUT copying the work from the first coffeepot coffeePot3_BaseAddress = Add_CoffeePotToSystem_PlugAndPlay(COFFEEPOT3, “Partner’s name");
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)
Catastrophic error on build
Can you see what the problem is?
NOTE: .h file names have been changed‐‐ fix
There is something wrong
here
Non‐printing character appeared when I cut and pasted the code from slides
Different errors from not having the code for simulator special features
•
•
•
•
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
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 pasted
from last presentation void TurnOnWater_CPP(COFFEEPOT_DEVICE *baseAddress, unsigned char waterInputLevel)
Pragma #message (Visual C++)
Pragma #warning (ADI CCES C++)
PRAGMA – compiler specific C++ extension
Use
#warning
on BF533
Use #message
in Visual CPP
Pseudo code for other functions
void PrepareTheCoffeePot_CPP (COFFEEPOT_DEVICE *baseAddress) { • Set the INITandSTAYPOWERED bit in control register
• Update the simulator
• In a loop
Update the simulator
Check it CONTROL REGISTER DEVICE_READY bit is on
Exit the loop if on
}
void TurnOnHeater_CPP(COFFEEPOT_DEVICE *baseAddress, unsigned char heaterLevel) {
Equivalent to TurnOnWater_CPP( ) function – different part of COFFEEPOT structure
}
Lets build and run the project
Design DEFECT recognized
We 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 said
unsigned char ReadControlRegister_CPP(COFFEEPOT_DEVICE *baseAddress );
Which makes the control register “unsigned char” – 8 bits
BIG QUIZ HINT
DESIGN ERROR – Found when we made the mistake before moving onto next phase of project
DESIGN 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 HAPPENS
AND 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
Enum issue (Editor problem)
Also – system is complaining about COFFEEPOT1 – even though that is a defined enum
in
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.
Hover over coffeePot1_BaseAddress ‐‐ 0x0000000 ‐‐ we are using illegal base address
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