# Basic CAN Project 1.4

## Purpose

This project uses the Controller Area Network (CAN).

## Hardware Requirements

This examples requires one of the following evaluation kits:

- AT91SAM7A3-EK
- AT91SAM7X-EK
- AT91SAM7XC-EK
- AT91SAM9263-EK

## Description

Upon startup, the program will configure the CAN, and make synchronization. If connected to other board, user can send a frame by pressing a key.

The basic will :

- CAN0 Mailbox 1, transmit, with acceptance mask
- CAN0 Mailbox 2, transmit, no acceptance mask
- Dump registers (for debug purpose)

## Usage

1. Build the program and download it inside the evaluation board. Please refer to the SAM-BA User Guide, the GNU-Based Software Development application note or to the IAR EWARM User Guide, depending on your chosen solution.
2. On the computer, open the DBGU port with a terminal application (e.g. HyperTerminal on Microsoft Windows).

- Settings: 115200 bauds, 8 bits, 1 stop bit, no parity, no flow control.

3. If you have 2 boards:

- Connect the CAN D+ board 1 to the CAN D+ board 2, and then CAN D- board 1 to the CAN D- board 2.
- Run the software on the 2 boards. You should get the following traces:

  > `BOARD 1: (we press the key 1)
  > -- Basic CAN Project 1.4 --
  > -- AT91SAM7X-EK
  > IP version: 0x121
  > CAN_Synchronisation
  > -I- CAN0 Initialisations Completed
  > INIT OK
  > CAN0 Mailbox 1, transmit, with acceptance mask
  > BOARD 2:
  > -- Basic CAN Project 1.4 --
  > -- AT91SAM7X-EK
  > IP version: 0x121
  > CAN_Synchronisation
  > -I- CAN0 Initialisations Completed
  > INIT OK
  > Press a Key [1:transmit 2:transmit 3:dump register]
  > Receive Maibox Number: 5
  > Read data low 0xAABBCCDD
  > Read data high 0x11223344
  > CAN0 Mailbox 1, transmit, with acceptance mask
  > Dump registers
  > CAN_MR: 0x1
  > CAN_IMR: 0x1F0000FF
  > CAN_SR: 0x610000
  > CAN_BR: 0x23534
  > CAN_ECR: 0x0
  > CAN_MB_MMR: 0x1000000
  > CAN_MB_MAM: 0x20080000
  > CAN_MB_MID: 0x80000
  > CAN_MB_MSR: 0x0
  > CAN_MB_MDL: 0x0
  > CAN_MB_MDH: 0x0
  > `

4. With the AT91SAM7A3:

- The AT91SAM7A3 has 2 can on its board. For the test, no need of 2 boards. Only connect CAN1 D+ to CAN2 D+ and CAN1 D- ton CAN2 D+.
- Launch the software. The software make a test of the 2 can. You should get the following output on the DBGU:

  > `-- Basic CAN Project 1.4 --
  > -- AT91SAM7A3-EK
  > IP version: 0x121
  > CAN_Synchronisation
  > -I- CAN0 Initialisations Completed
  > -I- CAN1 Initialisations Completed
  > With Interrupt CAN0 Mailbox 0 transmitting to CAN1 Mailbox 0
  > Test passed
  > With Interrupt CAN0 Mailboxes 1 & 2 transmitting to CAN1 Mailbox 15
  > Test passed
  > With Interrupt CAN0 Mailboxes 1 & 2 transmitting to CAN1 Mailbox 15
  > Wait, wait, wait, wait
  > Test passed
  > With Interrupt CAN0 Mailbox 3 asking for CAN1 Mailbox 3 transmission
  > Test passed
  > Without Interrupt CAN0 Mailbox 0 transmitting to CAN1 Mailbox 0
  > Test passed
  > Without Interrupt CAN0 Mailboxes 1 & 2 transmitting to CAN1 Mailbox 15
  > Test passed
  > Without Interrupt CAN0 Mailboxes 1 & 2 transmitting to CAN1 Mailbox 15
  > Test passed
  > Without Interrupt CAN0 Mailbox 3 asking for CAN1 Mailbox 3 transmission
  > Test passed
  > `

###### Atmel Corporation ©2008