SAMV71 Xplained Ultra Software Package 1.5

TWI Slave Example

Purpose

This project demonstrates the TWI peripheral in slave mode. It mimics the behavior of a serial memory, enabling the TWI master to read and write data in its internal SRAM.

Requirements

This package can be used with SAM V71 Xplained Ultra board or SAME70 Xplained board.

Description

After launching the program, the device will act as a simple TWI-enabled serial memory containing 256 bytes. This enables this project to be used with the twi_eeprom project as the master after modifying the slave address AT24MAC_ADDRESS as 0x53 in main.c.

To write in the memory, the TWI master must address the device first, then send one byte containing the memory address to access. Additional bytes are treated as the data to write.

Reading is done in the same fashion, except that after receiving the memory address, the device will start outputting data until a STOP condition is sent by the master.

Please connect the two SAMV71/SAME70 boards with the following pins which could be easily wired from the board.

Usage

  1. Build the program and download it inside the board. Please refer to the Getting Started with SAM V71/E70 Microcontrollers.pdf
  2. On the computer, open and configure a terminal application (e.g. HyperTerminal on Microsoft Windows) with these settings:
    • 115200 baud rate
    • 8 bits of data
    • No parity
    • 1 stop bit
    • No flow control
  3. Start the application.
  4. In the terminal window, the following text should appear (values depend on the board and chip used):
         -- TWI Slave Example xxx --
         -- SAMxxxxx-xx
         -- Compiled: xxx xx xxxx xx:xx:xx --
         -I- Configuring the TWI in slave mode
    
  5. For the TWI Master board, see the description inside his project
  6. and the "Master" board will output:
         -- TWI EEPROM Example xxx --
         -- SAMxxxxx-xx
         -- Compiled: xxx xx xxxx xx:xx:xx --
         -I- Filling page #0 with zeroes ...
         -I- Filling page #1 with zeroes ...
         ......
         -I- 0 comparison error(s) found
         ......
         -I- 0 comparison error(s) found
    

References

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines