PWM on AVR ATmega128L

ChibiOS public support forum for topics related to the Atmel AVR family of micro-controllers.

Moderators: utzig, tfAteba

pendekar
Posts: 4
Joined: Sun Jul 31, 2011 2:07 pm

PWM on AVR ATmega128L

Postby pendekar » Mon Sep 19, 2011 8:06 am

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

User avatar
Giovanni
Site Admin
Posts: 14458
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: PWM on AVR ATmega128L

Postby Giovanni » Mon Sep 19, 2011 8:17 am

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

pendekar
Posts: 4
Joined: Sun Jul 31, 2011 2:07 pm

Re: PWM on AVR ATmega128L

Postby pendekar » Mon Sep 19, 2011 9:00 am

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..

User avatar
Giovanni
Site Admin
Posts: 14458
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: PWM on AVR ATmega128L

Postby Giovanni » Mon Sep 19, 2011 9:32 am

Is AVR_PWM_USE_TIM1 set to TRUE in mcuconf.h and pwm_lld.h?

pendekar
Posts: 4
Joined: Sun Jul 31, 2011 2:07 pm

Re: PWM on AVR ATmega128L

Postby pendekar » Mon Sep 19, 2011 12:06 pm

yes, AVR_PWM_USE_TIM1 is set to TRUE.

User avatar
Giovanni
Site Admin
Posts: 14458
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: PWM on AVR ATmega128L

Postby Giovanni » Mon Sep 19, 2011 12:54 pm

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.

pendekar
Posts: 4
Joined: Sun Jul 31, 2011 2:07 pm

Re: PWM on AVR ATmega128L

Postby pendekar » Tue Sep 20, 2011 12:30 pm

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.
Attachments
PWM.rar
(249.95 KiB) Downloaded 352 times

User avatar
Giovanni
Site Admin
Posts: 14458
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: PWM on AVR ATmega128L

Postby Giovanni » Wed Sep 21, 2011 11:20 am

Your macros PWM_COMPUTE_FAST, PWM_COMPUTE_PHASE, PWM_COMPUTE_PHASEFREQ all have a missing ')'.

Giovanni


Return to “AVR Support”

Who is online

Users browsing this forum: No registered users and 3 guests