meggy jr simple and avr
play

Meggy Jr Simple and AVR Plan for today: ATmega328p chip AVR - PowerPoint PPT Presentation

Meggy Jr Simple and AVR Plan for today: ATmega328p chip AVR assembly CS453 Lecture Meggy Jr Simple and AVR 1 Example Meggy Java program /** * PA2twodots * Lights up two pixels: (col 1,row 2):red (3,4) :white * MMS, 2/5/13


  1. Meggy Jr Simple and AVR Plan for today: – ATmega328p chip – AVR assembly CS453 Lecture Meggy Jr Simple and AVR 1

  2. Example Meggy Java program /** � * PA2twodots � * Lights up two pixels: (col 1,row 2):red (3,4) :white � * MMS, 2/5/13 � */ � import meggy.Meggy; � class PA2twodots { � public static void main(String[] whatever){ � Meggy.setPixel( (byte)1, (byte)2, Meggy.Color.RED ); � Meggy.setPixel( (byte)3, (byte)4, Meggy.Color.WHITE ); � } � } � CS453 Lecture Meggy Jr Simple and AVR 2

  3. Meggy Java Three ways to execute a Meggy Java program: (1) Java-only using the meggy package that contains the Meggy class and interface. javac TestProg.java java TestProg (2) Compile to .s this is what you are building in this class, then: (2.1) Simulate AVR assembly code with MJSIM java -jar MJSIM.jar // for GUI java -jar MJSIM.jar -b -f ExampleFile.java.s // for command line (2.2) Create executable from .s, download on device, run on device. CS453 Lecture Meggy Jr Simple and AVR 3

  4. Java-Only Meggy Java meggy package à à go look at Meggy interface arg_opts input file – format int bool (button* delay)* - What kind of grammar describes arg_opts? CS453 Lecture Meggy Jr Simple and AVR 4

  5. Using MJSIM Authors – Ryan Moore did the initial design and prototype – Michelle Strout made it work with the assignments in 453 – Cassie Helms added the emulator – Laura Adams added the feature where it takes pictures of state Also uses an arg_opts file if one is available. Keep in mind that the simulator does not cover all of AVR assembly. Execute MJSIM.jar (java –jar MJSIM.jar) and find (via help) the List of supported instructions. CS453 Lecture Meggy Jr Simple and AVR 5

  6. avr-gcc tool chain See Resources page: Building programs for the Meggy and Guide for Programming with Arduino and MeggyJrSimple interface Also, read the meggy library code and .h file CS453 Lecture Meggy Jr Simple and AVR 6

  7. Meggy Jr Simple Library Key concepts – LED screen (pixels) – Auxiliary LEDs – Buttons – Speaker – Check the AVR-G++ generated code for library calls, and their calling sequence. AVR-G++ (and also MeggyJava) links in run time libraries: – Meggy Jr Library provided an interface to set and read values in the Display Memory – Meggy Jr Simple lies on top of Meggy Jr library, and provides a higher level API with names for e.g. colors – Michelle Strout and students (honors projects / theses) added some functionality to the Meggy Jr Simple library CS453 Lecture Meggy Jr Simple and AVR 7

  8. Meggy Jr Simple Library functions ClearSlate() -- erase the whole slate DrawPx(x,y,color) -- set pixel (x,y) to color DisplaySlate() -- copy slate to LED Display Memory SetAuxLEDS(value) -- 8 LEDS above screen numbered 1, 2,4,..,128 (left to right) value is a byte encoding in binary which LEDs are set SETAuxLEDS(53) sets LEDS 1,4,16, and 32 ReadPx(x,y) -- returns byte value of pixel (x,y) CheckButtonsDown() -- sets 6 variables: Button_(A|B|Up|Down|Left|Right) GetButtons() returns a byte (B,A,Up,Down,Left.Right: 1,2,4,8,16,32) ToneStart(divisor, duration) -- starts a tone of frequency 8 Mhz/divisor for ~duration milliseconds There are predefined tones. Check out MeggyJrSimple.h CS453 Lecture Meggy Jr Simple and AVR 8

  9. Mapping Meggy Java Interface to Meggy Simple Interface Let ’ s run the MJSIMulator to see an example of how this works: PA2bluedot: Short (no stack code) version (from gcc compiler) (We will look at the supplied code after we studied the assembly language, in the next lecture.) CS453 Lecture Meggy Jr Simple and AVR 9

Recommend


More recommend