<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META content="MSHTML 5.00.3502.5390" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hello,</FONT></DIV>
<DIV><FONT face=Arial size=2>I made Nut compatibable board but my Xtal is on
12MHz</FONT></DIV>
<DIV><FONT face=Arial size=2>I use #define NUT_CPU_FREQ 12000000, but system
did'nt work.</FONT></DIV>
<DIV><FONT face=Arial size=2>After some test I found bug in module
timer.c</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=4><STRONG>Original source:</STRONG></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>void NutTimerInit(void)<BR>{<BR>#ifdef
NUT_CPU_FREQ<BR> /*<BR> * - Program
prescaler to output PCK0/32 and clear Timer0 on compare
match.<BR> * - Clear timer counter register to get the
first tick right.<BR> * - Write (CPU frequency /
(prescaler * 1KHz)) in the output compare.<BR>
* register, so we'll get a compare match interrupt every
millisecond.<BR> */<BR>#ifdef
__AVR_ATmega128__<BR> outp(BV(CS00) |
BV(<STRONG><U>CS20</U></STRONG>) | BV(WGM01),
TCCR0);<BR>#else<BR> outp(BV(CS00) | BV(CS02) | BV(CTC0),
TCCR0);<BR>#endif<BR> outp(0, TCNT0);<BR>
outp(NUT_CPU_FREQ / (128L * 1000), OCR0);<BR>
NutRegisterIrqHandler(&sig_OUTPUT_COMPARE0, NutTimer0Intr,
0);<BR> sbi(TIMSK, OCIE0);<BR>#else<BR>
NutComputeCpuClock();<BR> sbi(TIMSK,
TOIE0);<BR>#endif<BR>}<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>New souce:</FONT></DIV>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2>void NutTimerInit(void)<BR>{<BR>#ifdef
NUT_CPU_FREQ<BR> /*<BR> * - Program
prescaler to output PCK0/32 and clear Timer0 on compare
match.<BR> * - Clear timer counter register to get the
first tick right.<BR> * - Write (CPU frequency /
(prescaler * 1KHz)) in the output compare.<BR>
* register, so we'll get a compare match interrupt every
millisecond.<BR> */<BR>#ifdef
__AVR_ATmega128__<BR> outp(BV(CS00) |
BV(<STRONG><U>CS02</U></STRONG>) | BV(WGM01),
TCCR0);<BR>#else<BR> outp(BV(CS00) | BV(CS02) | BV(CTC0),
TCCR0);<BR>#endif<BR> outp(0, TCNT0);<BR>
outp(NUT_CPU_FREQ / (128L * 1000), OCR0);<BR>
NutRegisterIrqHandler(&sig_OUTPUT_COMPARE0, NutTimer0Intr,
0);<BR> sbi(TIMSK, OCIE0);<BR>#else<BR>
NutComputeCpuClock();<BR> sbi(TIMSK,
TOIE0);<BR>#endif<BR>}<BR></FONT></DIV></FONT></DIV>
<DIV><FONT face=Arial size=2>When compiled original source system is busy to
respond to intterupt request and have no time for other.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Vasil Atanasov</FONT></DIV></BODY></HTML>