Skip to content

althebaker43/avr_lcd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

avr_lcd

This is an AVR assembler library and sample programs for configuring and communicating with LCD controllers.

Current Status

Right now, the project is comprised of a single source file, "avr_lcd.asm", that contains a simple hello-world program. This is being tested against a development circuit including an ATMega328P microcontroller and a Newhaven LCD module. Expansion into a more general-use library will occur once the circuit starts operating properly with the test program.

Getting Started

This sections lists things that need to be done after checking out this project from the repository for the first time.

Install Atmel Studio

For now, this project is being developed solely with Atmel Studio. As soon as the code is proven to work with the development circuit, work will begin on converting the project for use with the AVR-GCC toolchain and SimulAVR simulator.

Setting the Stimulus File Path

To simulate the program and log register values using Atmel Studio's built-in simulator, you need to set the filepath for the stimulus file. The stimulus file tells the simulator which registers to track, where to record their values, and how long to run the program.

  1. Open the project in Atmel Studio.
  2. In the Solution Explorer pane, right-click on the "avr_lcd" project.
  3. Click on "Properties".
  4. Click on the "Tool" tab.
  5. Under selected debugger/programmer, select "Simulator".
  6. In the "Select Stimuli File for Simulator" section, click on the "Stimuli File" button, and select the stimulus file (has a "*.stim" extension) in the project directory.
  7. Save the project settings.

Install Python

Python 2.7+ is required to use the stim2vcd script that converts simulation outputs from Atmel Studio's built-in simulator to VCD files that can be viewed in any VCD viewer.

Install a VCD Viewer

A VCD viewer is required to view the waveforms generated by the simulator for debugging purposes. Wave 1.2 by Interconnect Systems Solutions is a good choice for Windows platforms.

Install WinAVR

If using the USBTiny AVR programmer from Adafruit, AVRDUDE is needed to communicate with it. AVRDUDE is included in WinAVR, which can be downloaded for free from the Internet. WinAVR also includes drivers needed to install the USBTiny.

Development Guidelines

Programming via USBTinyISP

An AVR can be programmed right from Atmel Studio by setting the USBTiny as an external tool. After installing WinAVR and setting up USBTiny for Windows, open up Atmel Studio and click on "Tools" > "External Tools..." to add a new external tool. Then fill out the following information (omit the quotes):

  • Title: "USBTiny Debug"
  • Command: Path to avrdude.exe (usually something like "C:\WinAVR-20100110\bin\avrdude.exe")
  • Arguments: "-p m328p -c usbtiny -U flash:w:Debug/$(ItemFileName).hex"
  • Initial Directory: "$(ProjectDir)"

Check the "Use Output window" checkbox so that you can verify that programming completes successfully.

Now, whenever you have the USBTiny connected to your computer and target board, click on "Tools" > "USBTiny Debug" to program the AVR on the board. Note that you must have the ASM file open in Atmel Studio for this to work.

Using stim2vcd

The stim2vcd Python script in the project directory can be used to convert output from the Atmel Studio simulator into a VCD file that can be examined in a VCD waveform viewer. This can also be set up as an external tool in Atmel Studio to simplify use. Click on "Tools" > "External Tools..." to add a new external tool, and fill out the following information (omit the quotes).

  • Title: "stim2vcd"
  • Command: Path to Python interpreter (usually something like "C:\Python27\python.exe")
  • Arguments: "stim2vcd.py $(ItemFileName).sim_out"
  • Initial Directory: "$(ProjectDir)

Check the "Use Output window" checkbox so that you can verify that the script runs successfully.

Everytime you run a simulation, you can run stim2vcd by clicking "Tools" > "stim2vcd". Then, open up the resulting VCD file in a viewer to view the waveforms.

Running Simulations

Atmel Studio's built-in simulator can simulate the program running in a virtual ATMega328P and record changes in the values of selected registers over time. This is done with direction from a stimulus file, explained above. To run a simulation with the stimulus file, follow these steps:

  1. Click on "Debug" > "Start Debugging and Break" (or press Alt+F5).
  2. After the debugging environment is loaded, click on "Debug" > "Execute Stimulifile".
  3. Click on "Debug" > "Continue" (or press F5).
  4. Wait for the simulation run to finish. In the "Output" pane, show output from "FileStimuliProvider" and verify that the full contents of the stimuli file are shown, followed by "All stimuli files closed".
  5. Click on "Debug" > "Stop Debugging" (or press Ctrl+Shift+F5) to exit out of the debugger.
  6. The "avr_lcd.sim_out" file should now be present in the project directory. Run the stim2vcd script to generate a VCD file and examine the output in a VCD viewer.

About

An AVR assembler library for configuring and communicating with LCD controllers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published