To design, simulate, build and test both a hardware and software interface between the ATmega32A (OUSB-IO Board) and an external matrix keypad.

AIMS

  1. To develop an appreciation of the design workflow when writing code (firmware) for the ATmega32A microcontroller using the Microchip Studio 7.0 Integrated Development Environment (IDE).
  2. To design, simulate, build and test both a hardware and software interface between the ATmega32A (OUSB-IO Board) and an external matrix keypad.
  3. To construct an interface (via simulation / physical hardware) that displays the digits entered on a keypad and then perform fundamental mathematical operations.
  4. To build and contrast an application written in both Assembler and C and then deploy it to a physical target board after a successful simulation.
  5. To interpret design specifications from a worded description and successfully implement the corresponding firmware.

 Section A

This laboratory is split into three sections of which all need to be successfully completed to be awarded full marks. The first step in the process is to examine and extend the provided Assembler code to read the switches and drive the LEDs. You will start with a code template and enhance so that (eventually) it:

  1. Reads a value from the 16-key scanned keypad;
  2. Converts the value from a scan-code to hexadecimal and,
  3. Displays the results on the LEDs on the OUSB board.

Section B

The second part of the laboratory extended the currently designed system to use a 16-digit matrix keypad in place of the Port C switches. Figure 7 depicts a simplified view of the keypad that will be used in the practical component of this laboratory. Note that it does vary from Figure 3 as the inverters are not included.

When designing a program to interface with the matrix keypad there are two important features to note:

  • The keypad structure used in this laboratory is simpler than the one depicted in Figure 3 as the inverters are not included.
  • The pull-up resistors are internal to the ATmega32A microcontroller as part of the port structure (noted on the schematic). Page 57 of the ATmega32A datasheet [2] manual describes how this works as: “If PORTxn is written logic one when the pin is configured as an input pin, the pull-up resistor is activated. How will this be handled by the program? Can you see how this works in hardware (look at Figure 4)?
  • The I/O is now via Port C and the lines are different to the previous example. This makes it identical to the units you can buy online, which simplifies the scanning routine. The reference datasheet for the Keypad has also been uploaded to the subject Canvas website.