go_away

Author Topic: timer.c compiling error for AVRlib  (Read 6930 times)

0 Members and 1 Guest are viewing this topic.

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
timer.c compiling error for AVRlib
« on: May 16, 2007, 01:18:43 PM »
While trying to get rprintf() to work on my ATmega644, I get this error when compiling my file and cant figure it out . . .

Quote
Compiling: timer.c
avr-gcc -c -mmcu=atmega644 -I. -gstabs   -O0 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Wall -Wstrict-prototypes -Wa,-adhlns=timer.lst  -std=gnu99 -Wp,-M,-MP,-MT,timer.o,-MF,.dep/timer.o.d timer.c -o timer.o
timer.c: In function 'timer0Init':
timer.c:98: error: 'TIMSK' undeclared (first use in this function)
timer.c:98: error: (Each undeclared identifier is reported only once
timer.c:98: error: for each function it appears in.)
timer.c: In function 'timer1Init':
timer.c:109: error: 'TIMSK' undeclared (first use in this function)
timer.c: In function 'timer2Init':
timer.c:118: error: 'TIMSK' undeclared (first use in this function)
timer.c: In function 'timer0SetPrescaler':
timer.c:127: error: 'TCCR0' undeclared (first use in this function)
timer.c: In function 'timer2SetPrescaler':
timer.c:140: error: 'TCCR2' undeclared (first use in this function)
timer.c: In function 'timer0GetPrescaler':
timer.c:147: error: 'TCCR0' undeclared (first use in this function)
timer.c: In function 'timer2GetPrescaler':
timer.c:163: error: 'TCCR2' undeclared (first use in this function)
timer.c: At top level:
timer.c:464: warning: 'SIG_OUTPUT_COMPARE2' appears to be a misspelled signal handler
make: *** [timer.o] Error 1


upon google searching the error I found this:
http://www.mail-archive.com/[email protected]/msg02053.html

he got this response, but i dont really understand what I need to do to resolve the problem:
http://www.mail-archive.com/[email protected]/msg02054.html

searching through the various AVR library files i cant seem to find where TIMSK is declared, leading me to believe this has something to do with the problem . . .

(I didnt post my code because there is tons of it related to this problem)

ideas? ???

Offline JonHylands

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 562
  • Helpful? 3
  • Robot Builder/ Software Developer
Re: timer.c compiling error for AVRlib
« Reply #1 on: May 16, 2007, 01:44:16 PM »
On page 104 of the ATmega644, they describe:

TIMSK0 Timer/Counter Interrupt Mask Register

Sounds like a bug in the timer0Init function...

- Jon

Offline snow

  • Full Member
  • ***
  • Posts: 73
  • Helpful? 0
Re: timer.c compiling error for AVRlib
« Reply #2 on: May 17, 2007, 02:21:19 AM »
Hi!

I havent worked much with avr's so far, but i think that register TIMSK doesnt exist at all. You have TIMSK0, TIMSK1... Each register for each timer.
And TCCR0 are dividend into two registers: TCCR0A and TCCR0B.

And i believe they are defined in header (.h) files that come with compiler (e.g. gcc = winavr) and should be the same as they are in datasheet: http://www.atmel.com/dyn/resources/prod_documents/doc8011.pdf.

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: timer.c compiling error for AVRlib
« Reply #3 on: May 17, 2007, 11:48:58 AM »
ok I fixed the problem.

Apparently with the ATmega644 you cant use timer.c and timer.h.

Instead, I changed it to timerx8.c and timerx8.h.

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: timer.c compiling error for AVRlib
« Reply #4 on: May 17, 2007, 12:19:59 PM »
ok one other problem, potentially related to the above . . .

so I am getting these two warnings (not errors):
uart.c:70: warning: pointer targets in passing argument 2 of 'bufferInit' differ in signedness
uart.c:72: warning: pointer targets in passing argument 2 of 'bufferInit' differ in signedness

both of these are also from AVRlib . . . google search reveals nothing useful . . . there are no other buffer header files to use . . .

looking at part of uart.c:
Code: [Select]
// create and initialize the uart transmit and receive buffers
void uartInitBuffers(void)
{
#ifndef UART_BUFFERS_EXTERNAL_RAM
// initialize the UART receive buffer
bufferInit(&uartRxBuffer, uartRxData, UART_RX_BUFFER_SIZE); //line 70
// initialize the UART transmit buffer
bufferInit(&uartTxBuffer, uartTxData, UART_TX_BUFFER_SIZE); //line 72
#else
// initialize the UART receive buffer
bufferInit(&uartRxBuffer, (u08*) UART_RX_BUFFER_ADDR, UART_RX_BUFFER_SIZE);
// initialize the UART transmit buffer
bufferInit(&uartTxBuffer, (u08*) UART_TX_BUFFER_ADDR, UART_TX_BUFFER_SIZE);
#endif
}

It will probably take me a few weeks before I have all my wireless communication hardware working to test this, or otherwise I'd just upload the program and see what happens . . .

Offline JonHylands

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 562
  • Helpful? 3
  • Robot Builder/ Software Developer
Re: timer.c compiling error for AVRlib
« Reply #5 on: May 17, 2007, 01:30:12 PM »
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=280592

This guy seems to have run into a similar problem...

- Jon

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: timer.c compiling error for AVRlib
« Reply #6 on: May 17, 2007, 01:59:00 PM »
Yea that was the only link I was able to find, but after I looked into it further it turned out he was trying to solve a different unrelated error. :-\

Offline rgcustodio

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 0
  • Use "Search" and ye might find answers!
Re: timer.c compiling error for AVRlib
« Reply #7 on: May 24, 2007, 12:57:16 PM »
I've been using procyon's AVRlib for a few weeks now, and I've also stumbled on the errors/warnings you are encountering.


The "signedness" warning stems from the fact that in uart.c, uartRxData and uartTxData are defined as "char" only. The signedness of a "char" is machine dependent according to the gcc manual. On the other hand, uartInitBuffer() expects a u08, an "unsigned char". There lies the warning of different signedness.

One could probably:
1) apply a cast to the lines giving out a warning
2) change the data types of uartRxData and uartTxData so that it is unsigned
3) add -funsigned-char to your makefile, which makes "char" work like "unsigned char"

- Rommel
The best thing one can do when it's raining is to let it rain. - H. W. Longfellow

understanding is the path to enlightenment

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: timer.c compiling error for AVRlib
« Reply #8 on: June 01, 2007, 08:10:17 AM »
in uart.c i changed:
Code: [Select]
#ifndef UART_BUFFERS_EXTERNAL_RAM
// initialize the UART receive buffer
bufferInit(&uartRxBuffer, uartRxData, UART_RX_BUFFER_SIZE);
// initialize the UART transmit buffer
bufferInit(&uartTxBuffer, uartTxData, UART_TX_BUFFER_SIZE);

to:
Code: [Select]
#ifndef UART_BUFFERS_EXTERNAL_RAM
// initialize the UART receive buffer
bufferInit(&uartRxBuffer, (u08*) uartRxData, UART_RX_BUFFER_SIZE);
// initialize the UART transmit buffer
bufferInit(&uartTxBuffer, (u08*) uartTxData, UART_TX_BUFFER_SIZE);

and the warnings went away. Thanks!

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: timer.c compiling error for AVRlib
« Reply #9 on: July 17, 2008, 12:06:08 AM »
I made the change you suggested and still get the warning.  >:(
Code: [Select]
void uartInitBuffers(void)
{
#ifndef UART_BUFFERS_EXTERNAL_RAM
// initialize the UART receive buffer
bufferInit(&uartRxBuffer, (u08*) uartRxData, UART_RX_BUFFER_SIZE);
// initialize the UART transmit buffer
bufferInit(&uartTxBuffer, (u08*) uartTxData, UART_TX_BUFFER_SIZE);
#else
// initialize the UART receive buffer
bufferInit(&uartRxBuffer, (u08*) UART_RX_BUFFER_ADDR, UART_RX_BUFFER_SIZE);
// initialize the UART transmit buffer
bufferInit(&uartTxBuffer, (u08*) UART_TX_BUFFER_ADDR, UART_TX_BUFFER_SIZE);
#endif
}


Edit:  doh! it's complaining about line 187 here
Code: [Select]
if (uartReceiveByte(&myReceivedByte))     //  line 187
{
    // if there are bytes waiting on the serial port
    char inByte = uartGetByte(); // read a byte

what do I need to change?
« Last Edit: July 17, 2008, 12:42:56 AM by pomprocker »

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: timer.c compiling error for AVRlib
« Reply #10 on: July 17, 2008, 05:49:18 AM »
Hmmmm the error probably occurs before line 187.

Whats the error it gives?

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: timer.c compiling error for AVRlib
« Reply #11 on: July 17, 2008, 09:40:38 AM »
sorry forgot to include the exact error.

50_robot_sharp_ir.c:187: warning: pointer targets in passing argument 1 of 'uartReceiveByte' differ in signedness
« Last Edit: July 17, 2008, 09:41:13 AM by pomprocker »

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: timer.c compiling error for AVRlib
« Reply #12 on: July 17, 2008, 09:51:55 AM »
so . . . the code that i have online should already work . . . was it broken before you made these changes?

looking at my $50 sharp IR upgrade code in uart.c, this is what it's supposed to be:
Code: [Select]
// create and initialize the uart transmit and receive buffers
void uartInitBuffers(void)
{
#ifndef UART_BUFFERS_EXTERNAL_RAM
// initialize the UART receive buffer
bufferInit(&uartRxBuffer, uartRxData, UART_RX_BUFFER_SIZE);
// initialize the UART transmit buffer
bufferInit(&uartTxBuffer, uartTxData, UART_TX_BUFFER_SIZE);
#else
// initialize the UART receive buffer
bufferInit(&uartRxBuffer, (u08*) UART_RX_BUFFER_ADDR, UART_RX_BUFFER_SIZE);
// initialize the UART transmit buffer
bufferInit(&uartTxBuffer, (u08*) UART_TX_BUFFER_ADDR, UART_TX_BUFFER_SIZE);
#endif
}

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,430
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
Re: timer.c compiling error for AVRlib
« Reply #13 on: July 17, 2008, 09:54:57 AM »
Yeah I got that error before i made the change in uart.c. I'll look at it more again when I have time to play with it.

 


Get Your Ad Here