Society of Robots - Robot Forum

Software => Software => Topic started by: zverukas on October 12, 2010, 12:41:45 PM

Title: PROBLEM :New Tutorial : PWM on ATmega168
Post by: zverukas on October 12, 2010, 12:41:45 PM
Hi, i can't compile it on gcc.
I always receive an error: "../pwm.c:250:23: error: "*" may not appear in macro parameter list"
on lines :
#define pwmSet9(ICR1 * val /255)   OCR1A=val     
#define pwmSet10(ICR1 * val /255)   OCR1B=val

also warnings : "../pwm.c:135: warning: implicit declaration of function 'sbi'"
on :
void pwmOn9(void) {
   /****************************/
   /* Pin 9 on*/
   /****************************/
//9 A on - set at Bottom, clear at compare match
   sbi(TCCR1A,7);
  cbi(TCCR1A,6);

any ideas ? :-\
Title: Re: PROBLEM :New Tutorial : PWM on ATmega168
Post by: Webbot on October 12, 2010, 12:51:54 PM
Hi, i can't compile it on gcc.
I always receive an error: "../pwm.c:250:23: error: "*" may not appear in macro parameter list"
on lines :
#define pwmSet9(ICR1 * val /255)   OCR1A=val     
#define pwmSet10(ICR1 * val /255)   OCR1B=val
Yep - not surprised - that #define is full of errors. The original author of that tutorial was airman00. Hopefully you will get a response from him and he will fix the tutorial.


Quote
also warnings : "../pwm.c:135: warning: implicit declaration of function 'sbi'"
on :
void pwmOn9(void) {
   /****************************/
   /* Pin 9 on*/
   /****************************/
//9 A on - set at Bottom, clear at compare match
   sbi(TCCR1A,7);
  cbi(TCCR1A,6);

any ideas ? :-\

The cbi and sbi marcros aren't defined
Try placing this at the top of your program-
Code: [Select]
#ifndef cbi
    #define cbi(reg,bit)    reg &= ~(BV(bit))
#endif
#ifndef sbi
    #define sbi(reg,bit)    reg |= (BV(bit))
#endif
Title: Re: PROBLEM :New Tutorial : PWM on ATmega168
Post by: zverukas on October 12, 2010, 01:46:25 PM
hmm ::)

../pwm.c:142: warning: implicit declaration of function 'BV'
Title: Re: PROBLEM :New Tutorial : PWM on ATmega168
Post by: KurtEck on October 12, 2010, 01:54:43 PM
My quick guess at this is BV is probably defined something like:

#define BV(bit) (1<<bit)

You can probably put this in an #ifndef like the other ones...

Kurt