55
Hogeschool van Utrecht / Institute for Computer, Communicati on and Media Technology 1 2TPRJ8 – 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

Wouter van Ooijen Mail: [email protected] Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Embed Size (px)

DESCRIPTION

hardware en ontwikkelomgeving voor 2TPRJ8. Wouter van Ooijen Mail: [email protected] Sheets en info: www.voti.nl/hvu/2TPRJ8 www.voti.nl/hvu/arm. onderwerpen. het ARM bordje V2.3 de ‘hartslagmeter’ DevEnv – opstarten, editen, compileren debuggen met Insight - PowerPoint PPT Presentation

Citation preview

Page 1: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

12TPRJ8 – hardware en ontwikkelomgeving

Wouter van OoijenMail: [email protected]

Sheets en info:www.voti.nl/hvu/2TPRJ8

www.voti.nl/hvu/arm

hardware en ontwikkelomgeving voor 2TPRJ8

Page 2: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

22TPRJ8 – hardware en ontwikkelomgeving

het ARM bordje V2.3 de ‘hartslagmeter’ DevEnv – opstarten, editen,

compileren debuggen met Insight downloaden met OCD Commander het BSP opdrachten

Page 3: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

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

Page 4: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

42TPRJ8 – hardware en ontwikkelomgeving

Page 5: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

52TPRJ8 – hardware en ontwikkelomgeving

LPC2106 (ARM chip)

Page 6: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

62TPRJ8 – hardware en ontwikkelomgeving

Page 7: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

72TPRJ8 – hardware en ontwikkelomgeving

Page 8: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

82TPRJ8 – hardware en ontwikkelomgeving

Page 9: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

92TPRJ8 – hardware en ontwikkelomgeving

Page 10: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

102TPRJ8 – hardware en ontwikkelomgeving

Hangt aan I/O pin 16

Page 11: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

112TPRJ8 – hardware en ontwikkelomgeving

Page 12: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

122TPRJ8 – 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,

lpc21isp C++ BSP/RTOS

Page 13: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

132TPRJ8 – 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

Page 14: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

142TPRJ8 – hardware en ontwikkelomgeving

PsPad editormet GNU toolsvoor ARMasm/C/C++ontwikkeling

Page 15: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

152TPRJ8 – hardware en ontwikkelomgeving

build

foutmeldingen

Page 16: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

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 nauwelijks debuggen.

jullie werken uitsluitend in RAM.

Page 17: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

172TPRJ8 – hardware en ontwikkelomgeving

sluit het bordje aan (USB + parallel)

Page 18: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

182TPRJ8 – hardware en ontwikkelomgeving

Dit is de setting voor JTAG

Page 19: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

192TPRJ8 – hardware en ontwikkelomgeving

start debugger

Page 20: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

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)

Page 21: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

212TPRJ8 – hardware en ontwikkelomgeving

run > download

Page 22: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

222TPRJ8 – hardware en ontwikkelomgeving

Page 23: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

232TPRJ8 – hardware en ontwikkelomgeving

continue

Page 24: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

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

Page 25: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

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)

Page 26: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

262TPRJ8 – hardware en ontwikkelomgeving

Je kan variabelen (en andere lijsten) bekijken

Page 27: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

272TPRJ8 – hardware en ontwikkelomgeving

Je kan regel voor regel het programma uitvoeren

Page 28: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

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

Page 29: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

292TPRJ8 – hardware en ontwikkelomgeving

Na een ‘stop’ zit je meestal ergens in assembler

Page 30: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

302TPRJ8 – hardware en ontwikkelomgeving

start de OCD Commander

Page 31: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

312TPRJ8 – hardware en ontwikkelomgeving

check

Page 32: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

322TPRJ8 – hardware en ontwikkelomgeving

Load file

Page 33: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

332TPRJ8 – hardware en ontwikkelomgeving

Page 34: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

342TPRJ8 – hardware en ontwikkelomgeving

Page 35: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

352TPRJ8 – hardware en ontwikkelomgeving

run

Page 36: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

362TPRJ8 – hardware en ontwikkelomgeving

Page 37: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

372TPRJ8 – hardware en ontwikkelomgeving

HaltVoor je weer kan

laden

Page 38: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

382TPRJ8 – hardware en ontwikkelomgeving

Als je dit krijgt bij het linken heb je debugger/loader niet afgesloten

Page 39: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

392TPRJ8 – hardware en ontwikkelomgeving

Als je dit krijgt moet je dat ding installeren / starten.

Page 40: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

402TPRJ8 – 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

Page 41: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

412TPRJ8 – 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)

Page 42: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

422TPRJ8 – hardware en ontwikkelomgeving

Als het echt niet werkt: de USB aansluiting er even

uithalen om het bordje te resetten, evt ook je PC resetten.

Page 43: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

432TPRJ8 – 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

Page 44: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

442TPRJ8 – hardware en ontwikkelomgeving

class C_Busy {public:

// wait n microseconds void waitUs( int n );

// wait n milliseconds void waitMs( int n );

private: . . .

Page 45: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

452TPRJ8 – 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: ...

Page 46: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

462TPRJ8 – hardware en ontwikkelomgeving

class C_Timer {public: // abstract methodes: virtual unsigned long getMillisec( void ) = 0; virtual void registerCallback( void (* cb)( void ) ) = 0;

protected: . . .

Page 47: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

472TPRJ8 – hardware en ontwikkelomgeving

class C_Timer0 : public C_Timer { // C_Timer1 is similarpublic: // 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: . . .

Page 48: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

482TPRJ8 – 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: . . .

Page 49: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

492TPRJ8 – hardware en ontwikkelomgeving

class C_Beeper {public:

// switch the Beeper on (== high) void on( void );

// switch the Beeper off (== low) void off( void );

private: . . .

Page 50: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

502TPRJ8 – 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: . . .

Page 51: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

512TPRJ8 – 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: . . .

Page 52: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

522TPRJ8 – 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: . . .

Page 53: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

532TPRJ8 – 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.

Page 54: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

542TPRJ8 – 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).

Page 55: Wouter van Ooijen Mail:  wouter@voti.nl Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

552TPRJ8 – hardware en ontwikkelomgeving

opdrachten1. 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.