Host-Target Protocol


Detailed Description

Hardware connections

The protocol uses the MISO, MOSI and SCK lines of the AVR. The AVR is setup as a SPI slave and the PC is the SPI master. MOSI is tied to SS; PC controls the SS through the MOSI. line.

- PC -+                  +- AVR -
      |                  |
MISO  |------------<---- | MISO
      |                  |
MOSI  |------------>---- | MOSI
      |              |   |
      |              +-- | _SS
      |                  |
SCK   |------------>---- | SCK
------+                  +-------

Low-level protocol

Transmit from Target (AVR/Slave) to Host (PC/Master)
  1. Slave sets MISO high to indicate to master that it wants to send
  2. Slave waits for a transfer complete (this will potentially send a zero to the host).
  3. Slave reset MISO to high
  4. Master drives SS low (by driving MOSI low). When SS is driven low the MISO line is connected to the SP shift register
  5. Clocks SCK
  6. Reads bit from MISO before falling edge of SCK
  7. Releases SS to high indicating to slave that transfer is complete
  8. Since MOSI was driven low the SPI shift register contains zeros

Receive & transmit from target, setup is sck rising edge

                                7   6   5   4   3   2   1   0
                 ____________ ___ ___ ___ ___ ___ ___ ___ ___     
 MISO (trg)_____/          \_X___X___X___X___X___X___X___X___\___/\_________
                .                                                   .
           ________________                                       ____________ 
   SS (pc)                 \_____________________________________/  .   
                .          .                                     .  .   
           ______________  .  _   _   _   _   _   _   _   _   ________________  
  SCK (pc) ______________\___/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/________________ 
                .        . . . . . . . . . . . . . . . . . . .   .  .  .
                .....0....1.2.3.2.3.2.3.2.3.2.3.2.3.2.3.2.3.2..4....5...
               [A]        [B]                               [C] [D]

Flow and byte level protocol

All bytes sent from the target are in the following ranges: Each byte transmitted to the target is transmitted as 24 bits; each byte is by a 0011111111110000 header.

High level protocol

When the target is in running the monitor it sends a byte, AVR_MONITOR_SIGTRAP. When this is read from the target by the host switches to monitor mode and is ready to receive commands from the debugger.

Command packet host<->target

\

Defines

Enumerations


Define Documentation

#define AVR_MONITOR_SIGTRAP
 

Character sent by target to indicate that it is switching to monitor mode.

#define AVR_MONITOR_READY_TO_RECEIVE
 

Sent by target to indicate that it is in receive mode.

#define AVR_MONITOR_NODATA
 

Byte sent when monitor have no data to send Must be zero since the shift register is filled with zeros after a transfer


Enumeration Type Documentation

enum avr_monitor_cmd_t
 

Command to monitor in target.

Enumeration values:
AVR_MONITOR_CMD_EXIT  Exit monitor. See avr_monitor_run_mode_t.
AVR_MONITOR_CMD_READ_FLASH  Read program memory.
AVR_MONITOR_CMD_READ_SRAM  Read SRAM.
AVR_MONITOR_CMD_WRITE_SRAM  Write byte to SRAM.
AVR_MONITOR_CMD_GET_MON_DATA  Get address of monitor data and flashed breakpoints.
AVR_MONITOR_CMD_NOP  No operation.

enum avr_monitor_run_mode_t
 

Monitor run mode.

Enumeration values:
avr_monitor_continue  Go. Do not break on software breakpoints.
avr_monitor_step_asm_instruction  Step next asm instruction.
avr_monitor_step_to_next_bp  Step asm instructions until breakpoint.


Copyright 2002 Jörgen Birkler. For accelR8 Accelerometer on Mon Jan 19 21:43:20 2004 by Doxygen 1.3.5.