1 / 33

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

Wouter van Ooijen Mail: wouter@voti.nl Sheets en info: www.voti.nl/hvu/2TPRJ6 De hardware en ontwikkelomgeving voor 2TPRJ6. Even iets heel anders: 2TPRJ4

ebony
Download Presentation

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

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Wouter van Ooijen Mail: wouter@voti.nl Sheets en info: www.voti.nl/hvu/2TPRJ6 De hardware en ontwikkelomgeving voor 2TPRJ6 Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  2. Even iets heel anders: 2TPRJ4 • voor wie het aftekenen van de opdracht geeft gemist: herkansing in de volgende toest/organiatieperiode (datum komt tzt op mijn 2TPRJ4 pagina) • voor (bijna) iedereen: je moet je inschrijven, anders kan ik je geen cijfer geven! Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  3. de hardware • Philips ARM2106 microcontroller (64k RAM, 128k FLASH) • voeding uit USB (geen USB communicatie) • LCD 2x16 char (HD44780-compatible) • klein luidsprekertje • 16 schakelaars, uitlezen via schuifregisters • 8 LEDjes, aansturen via schuifregister • parallel JTAG programming interface (McGraigor) • RS232 serial interface • connector voor uitbreidingen Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

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

  5. Dit is de setting voor JTAG Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  6. de hardware 2 (sorry, volgende week pas…) • aansturing voor een LEGO motortje • aansluiting van een (twee?) hall sensoren Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

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

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

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

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

  11. de ontwikkelomgeving • PSPAD editor • GNU assmbler/C/C++ compiler • Insight debugger • MAC_MOT TCP-to-parallel JTAG interface • C++ BSP (board support package) Voorlopig werken jullie uitsluitend in RAM. Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  12. // The BSP class is a monad: you can create as many instances as you like, // but they will effectively all be the same instance. class C_BSP { public: // initialise is done automatically at startup, but it might be usefull // lateron (for instance after a power failure or another glitch) void Init( void ); C_Busy * Busy; C_Interrupts * Interrupts; C_Timer * Timer; C_Pins * Pins; C_LCD * LCD; C_Keyboard * Keyboard; C_LEDs * LEDs; C_BSP( void ); private: void Create( void ); }; Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  13. class C_Busy { public: // initialise is done automatically at startup, but it might be sefull // lateron (for instance after a power failure or another glitch) void Init( void ); // wait N us void WaitUs( int N ); // wait n ms void WaitMs( int N ); private: C_Busy( void ); void Create( void ); friend class C_BSP; }; Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  14. class C_Interrupts { public: void Init( void ); void RawEnable( void ); void RawDisable( void ); bool IsEnabled( void ); void UninterruptableBegin( void ); void UninterruptableEnd( void ); int UninterruptableCount( void ); private: ... }; Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  15. class C_Timer { public: void Init( void ); // schedule the specified function each millisecond // only one function can be scheduled, scheduling a new // function disables the previous one. void Schedule( void (*f)( void )); // return the number of 1ms Ticks since startup unsigned long int NrMillis( void ); private: ... }; Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  16. enum DirectionT { DirectionInput, DirectionOutput }; class C_Pins { public: void Init( void ); // set the direction of a pin void DirectionSet( unsigned char Pin, DirectionT Direction ); // get and set pin value // Set is most usefull when the pin direction is output // Get is most 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

  17. class C_LCD { public: void Init( void ); // 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 X,Y // X = column, 1 = leftmost // Y = line number, 1 = top line void Goto( unsigned char X, unsigned char Y ); // write a char at the write cursor position, // advance the write cursor position void Write( char Chr ); // For Command() and Data() no delay is added, so the caller // is responsible for the delay(s) required by the HD44780. // For Goto() and Write() the delays are added inside the calls. private: ... }; Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  18. 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: void Init( void ); // 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

  19. class C_LEDs { public: void Init( void ); // set the LEDs according to the 8 bits in Value void SetAll( unsigned char Value ); // switch the LED Nr on or off void SetOne( int Nr, bool Value ); private: ... }; Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  20. // The BSP class is a monad: you can create as many instances as you like, // but they will effectively all be the same instance. class C_BSP { public: // initialise is done automatically at startup, but it might be usefull // lateron (for instance after a power failure or another glitch) void Init( void ); C_Busy * Busy; C_Interrupts * Interrupts; C_Tick1ms * Tick1ms; C_Pins * Pins; C_LCD * LCD; C_Keyboard * Keyboard; C_LEDs * LEDs; C_BSP( void ); private: void Create( void ); }; Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  21. de ontwikkelomgeving LET OP! De I/O classes (LCD, Keyboard, LEDs) mogen niet uit de interrupt (ge-schedulde timertick) aangeroepen worden. Pinnen lezen en/of schrijven mag wel. Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  22. de ontwikkelomgeving LET OP! In de huidige versie van de linker scripts worden de allocators (initialisatie) van global objecten niet aageroepen! Gebruik dus locale objecten, evt. een global pointer naar zo’n object (of references doorgeven). Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  23. de ontwikkelomgeving De microcontroller heeft 64Kb RAM, maar daar moet alles in: code, globale data, stack. Wees dus “een beetje” zunig. Downloaden met de JTAG gaat niet erg snel. Zuinig zijn met code werkt dus sneller! Een classe op zich kost gen code, maar het gebruik van dynamisch geheugen wel! Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  24. de ontwikkelomgeving • sluit een bordje aan (parallel + USB) • 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 • build • start debugger Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  25. de ontwikkelomgeving zet onder file > target settings: • Target = Remote/TCP • Hostname = 127.0.0.1 • Port = 8888 (als je netjes afsluit blijft zou dit moeten blijven staan) Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  26. de ontwikkelomgeving • evt. kan je breakpoints zetten of verwijderen • run als het goed is kom je nu op een breakpoint aan het begin van main Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  27. de ontwikkelomgeving • continue Zoals het een embedded programma betaamt eindigt ons programma nooit. • stop Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  28. de ontwikkelomgeving Als je dit krijgt heb je debugger/loader niet afgesloten Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  29. de ontwikkelomgeving Als je dit krijgt moet 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

  30. de ontwikkelomgeving  Onder ‘external programs’ staat ook en entry om de MAC_MOT driver te her-installeren. Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  31. de ontwikkelomgeving  Als de die MAC_MOT driver niet kan vinden: installeer de Macraigor OCD commander (de link staat op www.voti.nl/hvu/2TPRJ6) Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

  32. de 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

  33. doen • Laat de LEDs knipperen: iedere seconde even (bv 200ms) aan • Zet ‘Hello world’ op het LCD scherm, en iets naar keuze op de tweede regel • Tel (op de LEDs of op de LCD) het aantal keren dat een bepaalde toest is ingedrukt (let op dender!). Hogeschool van Utrecht / Institute for Computer, Communication and Media Technology

More Related