User Tools

Site Tools


x0x:microprocessor

The Microprocessor

The processor of the x0xb0x is an ATmega162 microcontroller. There is a great site called AVR Freaks which appears to be for all things AVR.

The datasheet for the ATmega162 is available Here: 2513S.pdf. In depth documentation is available here: doc2513.pdf

Inputs and Outputs

Port A

7 6 5 4 3 2 1 0
LED Latch Rotary COM3 Rotary 1 Rotary 2 Rotary 4 Rotary 8 Tempow SW A Tempo SW B

Port B

7 6 5 4 3 2 1 0
SPL Clock SPL Out SPL In USB TX USB RX Switch Latch

Port C

Port C is concerned with Note, Accent, Rest and Slide Data.

When its output is 0x00, the x0xb0x interprets that as a rest

7 6 5 4 3 2 1 0
Accent Slide Note Data

Port D

Port D is for Midi and Din messages

7 6 5 4 3 2 1 0
DIN Sync Midi Out Midi In

Port E

2 1 0
Note Latch Gate

Summary of the Datasheet

What follows is a summary of the technical spec of the AtMega162 microcontroller(uC) as taken from the datasheet. It's purpose is to layout the basic information needed to look at the x0x firmware from an atomic level, examining not just the program flow, but how the microcontroller actually executes the code. No knowledge of microcontrollers is assumed, but it is advised that one looks over the datasheet as it contains many useful tables and graphs of the architechure of the uC.

Technical Summary

The AtMega162 is a high performance, low power 8-bit AVR uC which uses the efficient RISC architechure. It contains 16KByte of self programming flash program memory, 1KByte of SRAM and a 512 byte EEPROM. The AtMega162 is capable of a throughput of up to 16MIPS. The AtMege162 has a variety of peripheral features including 2 8-bit timer/counters 2 16-bit timer/counters and 6 PWM channels. For the execution of code the AtMega162 provides 32 8-bit working registers, all of which are connected to the Arithmetic Logic Unit. This allows two registers to be accesed in a single instruction cycle. The ALU can perform instructions on two registers or between a reister and a constant or simply on a single register. The status register provides information about the most recent Arithmetic operation. Program flow is provided by conditonal and unconditional jump and call instructions which can directly address the whole address space.

Questions

Now, that was very brief and there are a number of questions that are certain to be floating about.

  • Why three different types of memory?
  • How are they accessed by a program?
  • Where does the program reside?
  • What exactly are MIPS?
  • How are the timers implemented and how are they used in the code?
  • What part of the memory do the working registers belong?
  • Certianly we can see the usefulness of the ALU and the status register, but what are the instructions that allow us to use this in code?

Memory

The three types of memory are as follows:

  1. 16KB flash is the reprogrammable firmware storage. This is what actually contains code that the processor executes, and is what is written when you flash a new firmware to the chip. This is read-only as far as the firmware is concerned(?).
  2. 512B EEPROM is read/write persistant memory used for storing data. This is where your patterns are stored so that they are saved after rebooting. Also saved here is MIDI channel and tempo(?). See eeprom.h for functions that read and write to the EEPROM.
  3. 1KB SRAM is the realtime memory available to the running firmware to use. This is where variables and the stack live. This, more than anything, constrains how much the firmware can do at any one time.

The Status Register

The status register is an 8-bit register like the rest, however, each bit has it's own purpose. Below is a description of each.

* Bit 7: The Global Interrupt Enable Bit "I bit". This is responsible for enabling interupts on a global level. If this bit is not set, no interrupts will occur, reguardless of individual interupt settings. After each interupt this bit is cleared (set to 0) by the hardware and must be reset using RETI. CLI and SEI can be used to clear and set this bit manually.

*Bit 6: Bit Copy Storage "T bit". This bit provides a holding place for bit operations. Using BST and BLD a bit can be moved from a register into the T bit or moved from the T bit into a register.

*Bit 5: Half Carry Bit "H bit". This bit indicates a Half Carry and is useful in BCD operations. What is a BCD? Well, that'll have to wait a bit.. (bad pun intended..)

*Bit 4: Sign Bit "S bit". This bit is always a exclusive or of the Negative Flag (N bit) and the Two's Complement Overflow Flag (V Bit).

*Bit 3: Two's Complement Overflow Flag "V bit". This bit supports Two's Complement arithmetic. What is this? More to come..

*Bit 2: Negative Flag "N bit". This indicates a negative result

*Bit 1: Zero Flag "Z bit". This indicates a zero result.

*Bit 0: Carry Flag "C bit". This indicates a carry.

/home/ladyada/public_html/wiki/data/pages/x0x/microprocessor.txt · Last modified: 2016/01/28 18:05 (external edit)