Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
CodeVision AVR 1.25.7, user manual.pdf
Скачиваний:
236
Добавлен:
12.08.2013
Размер:
1.22 Mб
Скачать

CodeVisionAVR

5.14 Setting the 1 Wire Bus

By selecting the 1 Wire tab of the CodeWizardAVR, you can specify the 1 Wire bus configuration.

Using the 1 Wire Port list box you can specify which port is used for the implementation of the 1 Wire bus.

The Data Bit list box allows you to specify which port bit the 1 Wire bus uses.

© 1998-2007 HP InfoTech S.R.L.

Page 211

CodeVisionAVR

If you use the DS1820/DS18S20 temperature sensors, you must check the DS1820/DS18S20 Enabled check box.

If you use several DS1820/DS18S20 devices connected to the 1 Wire bus, you must check the Multiple Devices check box. Maximum 8 DS1820/DS18S20 devices can be connected to the bus. The ROM codes for these devices will be stored in the ds1820_rom_codes array.

The DS1820/DS18S20 devices can be accessed using the Maxim/Dallas Semiconductor DS1820/DS18S20 Temperature Sensors Functions.

© 1998-2007 HP InfoTech S.R.L.

Page 212

CodeVisionAVR

5.15 Setting the 2 Wire Bus

By selecting the 2 Wire (I2C) tab of the CodeWizardAVR, you can specify the 2 Wire bus interface configuration.

The AVR chip’s 2 Wire interface can be enabled by checking the 2 Wire Enabled check box. If the Generate Acknowledge Pulse check box is checked the ACK pulse on the 2 Wire bus is generated if one of the following conditions is met:

the device’s own slave address has been received;

a General Call has been received and the General Call Recognition check box is checked;

a data byte has been received in master receiver or slave receiver mode.

If the Generate Acknowledge Pulse check box is not checked, the chip’s 2 Wire interface is virtually disconnected from the 2 Wire bus. This check box will set the state of the TWEA bit of the TWCR register.

The Slave Address edit box sets the slave address of the 2 Wire serial bus unit. This address must be specified in hexadecimal and will be used to initialize the bits 1..7 of the TWAR register.

Checking the General Call Recognition check box, enables the recognition of the General Call given over the 2 Wire bus. This check box will set the state of the TWGCE bit of the TWAR register.

The Bit Rate list box allows you to specify maximum frequency of the pulses on the SCL 2 Wire bus line. It will affect the value of the TWBR register.

As both the receiver and transmitter may stretch the duration of the low period of the SCL line, when waiting for response, the frequency of the pulses may be lower than specified.

If the 2 Wire Interrupt check box is checked, the 2 Wire interface will generate interrupts. These interrupts will be serviced by the twi_isr function.

© 1998-2007 HP InfoTech S.R.L.

Page 213

CodeVisionAVR

5.16 Setting the CAN Controller

By selecting the CAN tab of the CodeWizardAVR, you can specify the CAN interface configuration.

The AVR chip's CAN interface can be enabled by checking the CAN Enabled check box.

The Interrupts list box allows enabling/disabling the following interrupts generated by the CAN controller:

CAN Timer Overrun interrupt, serviced by the can_timer_isr function

General Errors (bit error, stuff error, CRC error, form error, acknowledge error) interrupt, serviced by the can_isr function

Frame Buffer full interrupt, serviced by the can_isr function

MOb Errors interrupt, serviced by the can_isr function

Transmit completed OK interrupt, serviced by the can_isr function

Receive completed OK interrupt, serviced by the can_isr function

Bus Off interrupt, serviced by the can_isr function

All interrupts, except Timer Overrun, serviced by the can_isr function.

The Enable MOb Registers list box allows for individual enabling/disabling of the CAN Message Object registers.

The Enable MOb Interrupts list box allows for enabling/disabling the interrupts generated by individual Message Object registers.

The Highest Interrupt Priority MOb list box allows selecting the Message Object register that has the highest interrupt priority.

The CAN System Clock list box allows selecting the frequency of the CAN controller system clock. The Propagation Time Segment list box allows for compensation of physical delay times within the network. The duration of the propagation time segment must be twice the sum of the signal propagation time on the bus line, the input comparator delay and the output driver delay.

© 1998-2007 HP InfoTech S.R.L.

Page 214

CodeVisionAVR

The Re-Sync Jump Width list box allows for compensation of phase shifts between clock oscillators of different bus controllers, by controller re-synchronization on any relevant signal edge of the current transmission.

The Phase Segment 1 and Phase Segment 2 list boxes allow for compensation of phase edge errors.

The Sample Point(s) list box allows selecting the number of times (1 or 3) the bus is sampled. The CAN Timer Clock Period list box allows selecting the period of the CAN timer clock pulses.

The CAN Baud Rate is calculated based on the durations of the CAN System Clock, Propagation Time Segment, Phase Segment 1 and Phase Segment 2 parameters.

If the CAN Baud Rate value is correct it’s value is displayed in black color, otherwise it is displayed in red and must be corrected by modifying the above mentioned parameters.

© 1998-2007 HP InfoTech S.R.L.

Page 215