Page 1 of 1

PWM on AVR ATmega128L

Posted: Mon Sep 19, 2011 8:06 am
by pendekar
Hello,

Im trying implement PWM on ATmega128L. But, it's still got errors and warnings.
when i compile my code i got this :

main.c:55: warning: excess elements in array initializer
main.c:55: warning: (near initialization for 'pwmcfg.pc_channels')
main.c:56: warning: excess elements in array initializer
main.c:56: warning: (near initialization for 'pwmcfg.pc_channels')
main.c:58: warning: excess elements in struct initializer
main.c:58: warning: (near initialization for 'pwmcfg')
main.c:59: warning: implicit declaration of function 'PWM_COMPUTE_FAST'
main.c:59: warning: excess elements in struct initializer
main.c:59: warning: (near initialization for 'pwmcfg')
main.c: In function 'main':
main.c:82: error: 'PWMD1' undeclared (first use in this function)
main.c:82: error: (Each undeclared identifier is reported only once
main.c:82: error: for each function it appears in.)
make: *** [main.o] Error 1
Build failed with 3 errors and 9 warnings...

And my question is :
Why PWMD1 undeclared?
Is it because pwmd1 in here not linked to pwm_lld.h?

i have check that the PWM driver in halconf.h is enabled.
I dont know the cause that invoke those errors and warnings.
Need some advices here.
Thanks.

Regards

Re: PWM on AVR ATmega128L

Posted: Mon Sep 19, 2011 8:17 am
by Giovanni
Did your add your pwm_lld.c to \os\hal\platforms\AVR\platform.mk?

If no, add it.
If yes, does it export a variable named PWMD1? does pwm_lld.h include a extern declaration for said variable?

Giovanni

Re: PWM on AVR ATmega128L

Posted: Mon Sep 19, 2011 9:00 am
by pendekar
yes, already add it.

did you mean this

Code: Select all

#if AVR_PWM_USE_TIM1 && !defined(__DOXYGEN__)
extern PWMDriver PWMD1;
#endif


if so, then i already add it as well on External declarations pwm_lld.h.

and still invoke those errors..

Re: PWM on AVR ATmega128L

Posted: Mon Sep 19, 2011 9:32 am
by Giovanni
Is AVR_PWM_USE_TIM1 set to TRUE in mcuconf.h and pwm_lld.h?

Re: PWM on AVR ATmega128L

Posted: Mon Sep 19, 2011 12:06 pm
by pendekar
yes, AVR_PWM_USE_TIM1 is set to TRUE.

Re: PWM on AVR ATmega128L

Posted: Mon Sep 19, 2011 12:54 pm
by Giovanni
Does your main.c include hal.h ?

I am running out of ideas, I can't imagine what you could possibly done wrong. Post your code, better if a directly compilable project.

Re: PWM on AVR ATmega128L

Posted: Tue Sep 20, 2011 12:30 pm
by pendekar
oh well, it turn out to be my mistake when foldering files..

but, now i got new error.

main.c:61: error: expected expression before '}' token
main.c:61: warning: left-hand operand of comma expression has no effect
make: *** [main.o] Error 1
Build failed with 1 errors and 1 warnings...

And here is my code in attachment below.

Re: PWM on AVR ATmega128L

Posted: Wed Sep 21, 2011 11:20 am
by Giovanni
Your macros PWM_COMPUTE_FAST, PWM_COMPUTE_PHASE, PWM_COMPUTE_PHASEFREQ all have a missing ')'.

Giovanni