Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
12TPRJ8 – hardware en ontwikkelomgeving
Wouter van Ooijen
Mail: [email protected]
Sheets en info:
www.voti.nl/hvu/2TPRJ8
www.voti.nl/hvu/arm
hardware en ontwikkelomgeving voor 2TPRJ8
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
22TPRJ8 – hardware en ontwikkelomgeving
het ARM bordje de fiets DevEnv – opstarten, editen,
compileren debuggen met Insight downloaden met OCD Commander het BSP opdrachten
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
32TPRJ8 – hardware en ontwikkelomgeving
Philips ARM2106 microcontroller (64k RAM, 128k FLASH) voeding uit USB (maar geen USB communicatie) LCD 2x16 char (HD44780-compatible) klein luidsprekertje 16 schakelaars, uitlezen via 2 x HC165 schuifregisters 8 LEDjes, aansturen via 1 x HC595 schuifregister parallel JTAG programming interface (McGraigor Wiggler
compatibel) RS232 serial interface connector voor uitbreidingen
http://www.voti/nl/hvu/arm
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
42TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
52TPRJ8 – hardware en ontwikkelomgeving
LPC2106 (ARM chip)
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
62TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
72TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
82TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
92TPRJ8 – hardware en ontwikkelomgeving
snelheidsregeling voor een LEGO motortje
aansluiting van een hall (= magneet) sensor
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
102TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
112TPRJ8 – hardware en ontwikkelomgeving
PSPAD editor GNU assmbler/C/C++ compiler Insight debugger MAC_MOT TCP-to-parallel JTAG
interface
Los: OCD Commander, Philips flash tool C++ BSP/RTOS
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
122TPRJ8 – hardware en ontwikkelomgeving
installeer de files uit de BSP (BikeComputer.zip?) in een lege directory let op: geen spaties in de
pathname
dubbel-klik op de .ppr file
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
132TPRJ8 – hardware en ontwikkelomgeving
PsPad editormet GNU toolsvoor ARMasm/C/C++ontwikkeling
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
142TPRJ8 – hardware en ontwikkelomgeving
build
foutmeldingen
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
152TPRJ8 – hardware en ontwikkelomgeving
Als je dit krijgt bij het linken heb je debugger/loader niet afgesloten
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
162TPRJ8 – hardware en ontwikkelomgeving
De microcontroller heeft 64Kb RAM, maar daar moet alles in: code, globale data, stack. Wees dus “een beetje” zunig.
Downloaden met de de JTAG debugger gaat niet erg snel. Zuinig zijn met code werkt dus sneller! Een klasse op zich kost geen code, maar (klasse) variabelen en (klasse) functies wel!
Downloaden met de OCD Commander gaat veel sneller, maar je kan dan nauelijks debuggen.
Voorlopig werken jullie uitsluitend in RAM.
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
172TPRJ8 – hardware en ontwikkelomgeving
sluit het bordje aan (USB + parallel)
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
182TPRJ8 – hardware en ontwikkelomgeving
Dit is de setting voor JTAG
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
192TPRJ8 – hardware en ontwikkelomgeving
start debugger
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
202TPRJ8 – hardware en ontwikkelomgeving
zet onder file > target settings:Target = Remote/TCPHostname = 127.0.0.1Port = 8888
(als je netjes afsluit blijft zou dit moeten blijven staan)
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
212TPRJ8 – hardware en ontwikkelomgeving
run > download
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
222TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
232TPRJ8 – hardware en ontwikkelomgeving
continue
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
242TPRJ8 – hardware en ontwikkelomgeving
als het goed is kom je nu op het breakpoint aan het begin van main
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
252TPRJ8 – hardware en ontwikkelomgeving
Je kan breakpoints toevoegen of verwijderen(ook in andere source files)
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
262TPRJ8 – hardware en ontwikkelomgeving
Je kan variabelen (en andere lijsten) bekijken
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
272TPRJ8 – hardware en ontwikkelomgeving
Je kan regel voor regel het programma uitvoeren
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
282TPRJ8 – hardware en ontwikkelomgeving
continue
Zoals het een embedded programma betaamt eindigt ons programma nooit.
stop
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
292TPRJ8 – hardware en ontwikkelomgeving
Na een ‘stop’ zit je meestal ergens in assembler
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
302TPRJ8 – hardware en ontwikkelomgeving
start de OCD Commander
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
312TPRJ8 – hardware en ontwikkelomgeving
check
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
322TPRJ8 – hardware en ontwikkelomgeving
Load file
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
332TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
342TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
352TPRJ8 – hardware en ontwikkelomgeving
run
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
362TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
372TPRJ8 – hardware en ontwikkelomgeving
Halt
Voor je weer kan laden
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
382TPRJ8 – hardware en ontwikkelomgeving
Als je dit krijgt moet je dat ding installeren / starten.
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
392TPRJ8 – hardware en ontwikkelomgeving
Als je dit thuis krijgt kan je onder control panel > system > hardware > device manager (select view > show hidden devices) > non plug-and-pray devices > MAC_MOT > driver instellen op status = started, type = automatic
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
402TPRJ8 – hardware en ontwikkelomgeving
Als de thuis die MAC_MOT driver niet kan vinden: installeer de Macraigor OCD commander (de link staat op www.voti.nl/hvu/arm)
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
412TPRJ8 – hardware en ontwikkelomgeving
Als het echt niet werkt: de USB aansluiting er even
uithalen om het bordje te resetten, evt ook je PC resetten.
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
422TPRJ8 – hardware en ontwikkelomgeving
class C_BSP {
public:
// get the one and only BSP:
static C_BSP * getInstance( void );
C_Busy * busy;
C_Interrupts * interrupts;
C_Timer0 * timer0;
C_Timer1 * timer1;
C_Pins * pins;
C_Beeper * beeper;
C_LEDs * leds;
C_Keyboard * keyboard;
C_LCD * lcd;
private: . . .
Chip
On-board peripherals
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
432TPRJ8 – hardware en ontwikkelomgeving
class C_Busy {
public:
// wait n microseconds
void waitUs( int n );
// wait n milliseconds
void waitMs( int n );
private: . . .
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
442TPRJ8 – hardware en ontwikkelomgeving
class C_Interrupts {
public:
// Check whether interrupts are currently enabled.
bool isEnabled( void );
// guards for an region of code that must run uninterruptable
// these calls work properly when nested
void unInterruptableBegin( void );
void unInterruptableEnd( void );
// check the current nesting of uninterruptable regions
// probably usefull for debugging
int unInterruptableCount( void );
private: ...
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
452TPRJ8 – hardware en ontwikkelomgeving
class C_Timer {
public:
// abstract methodes:
virtual unsigned long getMillisec( void ) = 0;
virtual void registerCallback( void (* cb)( void ) ) = 0;
protected: . . .
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
462TPRJ8 – hardware en ontwikkelomgeving
class C_Timer0 : public C_Timer { // C_Timer1 is similar
public:
// The registered function is called on each timer interrupt
// Registering another function overwrites the previous.
// N.B. The function cb() should not do any I/O write operations
// neither directly nor indirectly!
void registerCallback( void (* cb)( void ) );
// static member for the routines to call if the timer ticks
static void (* callback)( void );
// handler called when timer interrupt occurs
static void timerInterruptHandler0 (void);
// static member for the number of milliseconds
static unsigned long nrMillis;
inline unsigned long getMillisec( void ){ return nrMillis; }
// clock frequency
static const unsigned CLOCK_FREQ;
private: . . .
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
472TPRJ8 – hardware en ontwikkelomgeving
enum DirectionT {
DirectionInput,
DirectionOutput };
class C_Pins {
public:
// set the direction of a pin
void setDirection( unsigned char pin,
DirectionT direction );
// get and set pin value
// set is usefull when the pin direction is output
// get is usefull when the pin direction is input
bool get( unsigned char pin );
void set( unsigned char pin, bool value );
private: . . .
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
482TPRJ8 – hardware en ontwikkelomgeving
class C_Beeper {
public:
// switch the Beeper on (== high)
void on( void );
// switch the Beeper off (== low)
void off( void );
private: . . .
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
492TPRJ8 – hardware en ontwikkelomgeving
class C_LEDs {
public:
// set the LEDs according to the 8 bits in value
void setAll( unsigned char value );
// switch the LED nr on or off
void setOne( unsigned char nr, bool value );
private: . . .
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
502TPRJ8 – hardware en ontwikkelomgeving
enum KeyT {
Key0 = 6, Key1 = 15, Key2 = 14, Key3 = 13, Key4 = 12,
Key5 = 11, Key6 = 10, Key7 = 9, Key8 = 8, Key9 = 7,
KeyA = 3, KeyB = 2, KeyC = 1, KeyD = 0,
KeyStar = 5, KeySharp = 4,
KeyNone = 0xFF };
class C_Keyboard {
public:
// read the keyboard, return
// whether a key is pressed
// and if so which one
KeyT read( void );
private: . . .
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
512TPRJ8 – hardware en ontwikkelomgeving
class C_LCD {
public:
// send a HD44780 command byte to the LCD
void command( unsigned char cmd );
// send a HD44780 data byte to the LCD
void data( unsigned char chr );
// put the write cursor at (row, col)
// row = line number, 0 = top line
// col = column, 0 = leftmost
void gotoRowCol( unsigned char row, unsigned char col );
// write a char at the write cursor position and
// advance the write cursor position
void write( char chr );
private: . . .
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
522TPRJ8 – hardware en ontwikkelomgeving
LET OP!De I/O classes (LCD, Keyboard, LEDs, etc) mogen niet uit
de interrupt (ge-schedulde timerticks) aangeroepen worden. Pinnen lezen en/of schrijven mag wel.
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
532TPRJ8 – hardware en ontwikkelomgeving
LET OP!In de huidige versie van de opstart code en linker scripts
worden de creators (initialisatie) van globale objecten niet aangeroepen! Gebruik dus locale objecten, evt. een globale pointer naar zo’n object (of references doorgeven).
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
542TPRJ8 – hardware en ontwikkelomgeving
opdrachten
1. Laat de LEDs knipperen: iedere seconde heel even (bv 200ms) aan.
2. Geluid: maak een korte piep (bv 1 seconde 1 kHz).
3. Zet ‘Hello world’ op het LCD scherm, en iets naar keuze op de tweede regel.
4. Laat op het LCD of de LEDs zien als toets 1 of toets 2 wordt ingedrukt.
Top Related