[an error occurred while processing this directive]
|
На прошлой неделе отлаживался по avr315.
По поводу TWPS 0x00 :(avr315, 4 стр)
TWPS is located in TWISR which is the same register as the TWI Status bits. TWPS
should therefore always be set to 0 to simplify the handling of the TWI Status bits.
Use TWBR to achieve the needed speed on the SCL. Table 1 shows a selection of
pre calculated TWBR values based on CPU and SCL frequencies.
По поводу падения в ноль SCL- это она не хочет себя мастером потерять, хоть ошибка на шине, вот и ждет реакции программы.
Смотри мой вариант окончания прерывания
case TWI_BUS_ERROR: // Bus error due to an illegal START or STOP condition
default:
TWI_state = TWSR; // Store TWSR and automatically sets clears noErrors bit.
// Reset TWI Interface
TWCR = (1<(0< (0< (0<
Еще в варианте AVR315 при ошибке по тупому предлагается повторить передачу, а при занятости шины ждать до посинения. Возможно отсюда зависание. Я сделал таймауты.
Еще скорость может ограничивать слейв, удержанием SCL до готовности.
Легко отлаживаться, если в прерывании выводить в putchar коды состояния шины, что помешало передаче пакета.
Типа:
//#pragma vector=TWI_vect
interrupt [TWI] void twi_isr(void)
{
static unsigned char TWI_bufPtr;
//dbug[dbug_counter]=TWSR;dbug_counter++ ;
// putchar1(TWSR); //????????????????????
switch (TWSR)
E-mail: info@telesys.ru