Wouter van Ooijen Mail: w[email protected] Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm
Embed Size (px)
description
Transcript of Wouter van Ooijen Mail: w[email protected] Sheets en info: voti.nl/hvu/2TPRJ8 voti.nl/hvu/arm

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
1
Wouter van Ooijen
Mail: [email protected]
Sheets en info:
www.voti.nl/hvu/2TPRJ8
www.voti.nl/hvu/arm
hardware en ontwikkelomgeving voor 2TPRJ8

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
2
het ARM bordje de fiets Virtual Machine - opstarten DevEnv – opstarten, editen,
compileren debuggen met Insight downloaden met OCD Commander het BSP opdrachten

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
3
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

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
4

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
5
LPC2106 (ARM
chip)

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
6
Uitlezen v.d. toetsjes

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
7
Aansturen v.d. LEDjes

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
8
JTAG interface
RS232 interface

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
9
snelheidsregeling voor een LEGO motortje
aansluiting van een hall (= magneet) sensor

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
10

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
11

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
12
Log in (met je email en password) ‘Start’ de Virtual Machine met het
Artisan image In de Virtual machine settings moet
de paralelle poort meegenomen worden
Nu kan je de Virtual Machine echt starten
Als je een USB stick wil gebruiken dan moet je die nu pas inpluggen

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
13

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
14

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
15

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
16

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
17

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
18
PSPAD editor GNU assmbler/C/C++ compiler Insight debugger MAC_MOT TCP-to-parallel JTAG
interface
Los: OCD Commander (Philips Flash utility) C++ BSP/RTOS

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
19
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

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
20
PsPad editormet GNU toolsvoor ARMasm/C/C++ontwikkeling

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
21
build
foutmeldingen

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
22
Als je dit krijgt bij het linken heb je debugger/loader niet afgesloten

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
23
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.
Jullie werken uitsluitend in RAM.

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
24
sluit het bordje aan (USB + parallel)

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
25
Dit is de setting voor JTAG

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
26
start debugger

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
27
zet onder file > target settings:Target = Remote/TCPHostname = 127.0.0.1Port = 8888
(als je netjes afsluit blijft zou dit moeten blijven staan)

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
28
run > download

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
29

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
30
continue

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
31
als het goed is kom je nu op het breakpoint aan het begin van main

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
32
Je kan breakpoints toevoegen of verwijderen
(ook in andere source files)

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
33
Je kan variabelen (en andere lijsten) bekijken

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
34
Je kan regel voor regel het programma uitvoeren

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
35
continue
Zoals het een embedded programma betaamt eindigt ons programma nooit.
stop

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
36
Na een ‘stop’ zit je meestal ergens in assembler

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
37
start de OCD Commander

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
38
check

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
39
Load file

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
40

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
41

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
42
run

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
43

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
44
Overnieuw:
Halt
Load file
Go

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
45
Als je dit krijgt moet je dat ding installeren / starten.

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
46
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

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
47
Als de thuis die MAC_MOT driver niet kan vinden: installeer de Macraigor OCD commander (de link staat op www.voti.nl/hvu/arm)

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
48
Als het echt niet werkt: de USB aansluiting
er even uithalen om het bordje te resetten, evt ook je PC resetten.

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
49
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

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
50
class C_Busy {
public:
// wait n microseconds
void waitUs( int n );
// wait n milliseconds
void waitMs( int n );
private: . . .

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
51
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: ...

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
52
class C_Timer {
public:
// abstract methodes:
virtual unsigned long getMillisec( void ) = 0;
virtual void registerCallback( void (* cb)( void ) ) = 0;
protected: . . .

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
53
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: . . .

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
54
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: . . .

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
55
class C_Beeper {
public:
// switch the Beeper on (== high)
void on( void );
// switch the Beeper off (== low)
void off( void );
private: . . .

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
56
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: . . .

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
57
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 );
// read the keyboard, to get
// the status of the given key
bool readKey ( KeyT key );

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
58
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: . . .

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
59
LET OP!1. De ‘hogere’ I/O classes (LCD, Keyboard, LEDs, etc)
mogen niet uit de interrupt (ge-schedulde timerticks) aangeroepen worden. Pinnen lezen en/of schrijven mag wel.
2. 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).

2TPRJ8 – hardware en ontwikkelomgeving
Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology
60
Opdrachten – vrijwillig, maar…
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.