Society of Robots - Robot Forum
Software => Software => Topic started by: Hasan999 on December 30, 2009, 06:19:45 PM
-
After a long time dealing with the "undefined reference" problem (including Axon.elf error) ...this is where I could reach..
I am using Axon_Source_012309 Source code with new Timer640.c/h files [i.e. i can see Timer640_old.c/h] - which apparently Admin made to fix the same errors of "undefined reference" etc that occurs while I use Timers !.
(btw, Axon.elf not found error still occurs when i #include "timer640.c" - what should I do?)
But anyway, now, when I added the Axon_Source_012309 Source code, with new Timer640 files (also attached) I got errors in Axon.c because of initializing Timers functions are different ! (that Admin used in the old and new Timer640.h)
For example: by default we have (in Axon.c):
init_timer0(TIMER_CLK_1024);
init_timer1(TIMER_CLK_64);
init_timer2(TIMER2_CLK_64);
init_timer3(TIMER_CLK_64);
init_timer4(TIMER_CLK_64);
init_timer5(TIMER_CLK_64);
But none of them (the functions or arguement variable etc) match the new Timer640.h ...
so I tried this and it didn't give me any error:
timer0SetPrescaler(TIMER_CLK_DIV1024);
timer1SetPrescaler(TIMER_CLK_DIV64);
timer2SetPrescaler(TIMERRTC_CLK_DIV64);
timer3SetPrescaler(TIMER_CLK_DIV64);
timer4SetPrescaler(TIMER_CLK_DIV64);
timer5SetPrescaler(TIMER_CLK_DIV64);
but I don't know much about it... does that Initialize it? ..if not, what would be the code for initializing the timers...?
Last thing: All the examples of Timers etc.. does not work..
For example, (to start the timer, and after 5 seconds run the servo) I'm using:
long time=timer0GetOverflowCount()*255+TCNT0;
timer0Init();
reset_timer_0();
while(time<5) ;
for(uint16_t i=0; i<10; i++){
servo(PORTA,7,700);}
No compiling errors, but it doesn't work !!
Please help me create Timers !...
Thanks !
-
IMHO this code will never work.
1: long time=timer0GetOverflowCount()*255+TCNT0;
2: timer0Init();
3: reset_timer_0();
4:
5: while(time<5) ;
6:
7: for(uint16_t i=0; i<10; i++){
8: servo(PORTA,7,700);}
assuming all of the H/W initialization was properly performed. The value of time is never updated.
In line 1 you assign a value to time.
In line 5 you check the value, if the assigned value in line 1 was greater than 5 the code in line 7 and 8 get a chance to execute.
BUT if the value assigned to time is less than 5 the loop enters an infinite loop, because time will always be less than 5 as there is no code to update the value of time.
-
ohh.... I thought that will enable the timer CLOCK !..
but how to do that?? ... how can I "start" the stop-watch and perform tasks at different times ?
Please help - thanks !!
-
I recommend just using the latest code version. There were some timer name changes made, so thats probably causing the initialization issues.