Цитата(_Pasha @ Sep 30 2013, 17:06)

Дык покажите свой porttimer.c и portserial.c и еще чего там меняли по сравнению с базовой демкой. Там же всё элементарно...

файл добавить не получается, поэтому пишу сам листинг. Примечание: исходные строчки не удалены, а закомментированы. Следом идут мои.
/*
* FreeModbus Libary: ATMega168 Port
* Copyright © 2006 Christian Walter <wolti@sil.at>
* Modified in 2010 by drvlas:
* Only RTU mode.
* Use T0 instead of T1. Implemented only on ATmega168
*/
/* ----------------------- AVR includes -------------------------------------*/
#include <avr/io.h>
#include <avr/interrupt.h>
//#include <avr/signal.h>
/* ----------------------- Platform includes --------------------------------*/
#include "../include/port.h"
/* ----------------------- Modbus includes ----------------------------------*/
#include "../include/mb.h"
#include "../include/mbport.h"
/* ----------------------- Defines ------------------------------------------*/
#define MB_TIMER_PRESCALER ( 1024UL )
#define MB_TIMER_TICKS ( F_CPU / MB_TIMER_PRESCALER )
#define MB_50US_TICKS ( 20000UL )
/* ----------------------- Static variables ---------------------------------*/
static USHORT usTimerOCRADelta;
//static USHORT usTimerOCRBDelta;
/* ----------------------- Start implementation -----------------------------*/
BOOL
xMBPortTimersInit( USHORT usTimerout50us )
{
/* Calculate overflow counter an OCR values for Timer0. */
usTimerOCRADelta =
( MB_TIMER_TICKS * usTimerout50us ) / ( MB_50US_TICKS );
if( usTimerOCRADelta > 255) return FALSE;
//TCCR0A = 0x00; // Normal Mode + Output Compare interrupt
TCCR0 = 0x00; // Normal Mode + Output Compare interrupt
//TCCR0B = 0x00;
TCCR2 = 0x00;
// TCCR1C = 0x00;
vMBPortTimersDisable( );
return TRUE;
}
inline void
vMBPortTimersEnable( )
{
TCNT0 = 0x0000;
if( usTimerOCRADelta > 0 )
{
//TIMSK0 |= _BV( OCIE0A );
TIMSK |= _BV( OCIE0 );
//OCR0A = usTimerOCRADelta; // MUST be < 256
OCR0 = usTimerOCRADelta; // MUST be < 256
}
//TCCR0B |= _BV( CS12 ) | _BV( CS10 ); // Fosc/1024
TCCR2 |= _BV( CS12 ) | _BV( CS10 ); // Fosc/1024
}
inline void
vMBPortTimersDisable( )
{
/* Disable the timer. */
//TCCR0B &= ~( _BV( CS12 ) | _BV( CS10 ) );
TCCR2 &= ~( _BV( CS12 ) | _BV( CS10 ) );
/* Disable the output compare interrupts for channel A */
//TIMSK0 &= ~( _BV( OCIE0A ) );
TIMSK &= ~( _BV( OCIE0 ) );
/* Clear output compare flags for channel A/B. */
//TIFR0 |= _BV( OCF0A ) ;
TIFR |= _BV( OCF0 ) ;
}
//SIGNAL( SIG_OUTPUT_COMPARE0A )
SIGNAL( SIG_OUTPUT_COMPARE0 )
{
( void )pxMBPortCBTimerExpired( );
}