Society of Robots - Robot Forum
Software => Software => Topic started by: ukesh on August 06, 2009, 09:54:19 AM
-
I'm writing a program to create an pulsing effect by using the led in axon mcu. The following, is the code in the control.c file.
void control(void)
{
ledpulse();
}
void ledpulse(void)
{
int i;
PWM_Init_timer1_LED(8);
PWM_timer1_On_LED();
while(1)
{
for(i=110;i<255;i++)
{
PWM_timer1_Set_LED(i);
delay_ms(10);//control pulse speed
}
for(i=255;i>110;i--)
{
PWM_timer1_Set_LED(i);
delay_ms(10);//control pulse speed
}
}
}
I have not changed anything in the Axon.c file. I've changed the target name in the makefile. I get the following error.
-
it looks like you didn't include a header file for the PWM functions, its saying that those aren't defined anywhere
-
it looks like you didn't include a header file for the PWM functions, its saying that those aren't defined anywhere
were can i find the header file for PWM functions? and where do i include the header file?
-
i dont know what file the axon one is in, but to include it you would do something like
#include "pwm_file_name.h"
this should go at the top of your code
-
i dont know what file the axon one is in, but to include it you would do something like
#include "pwm_file_name.h"
this should go at the top of your code
oh okie man, thanks.
can any users of axon guide me on finding the header file for pwm functions??
-
Its in timer640.c
http://www.societyofrobots.com/axon/axon_function_list.shtml#pwm
-
Its in timer640.c
http://www.societyofrobots.com/axon/axon_function_list.shtml#pwm
Do i need to add the header file timer640.h in the axon.c file ?
-
Its in timer640.c
http://www.societyofrobots.com/axon/axon_function_list.shtml#pwm
Do i need to add the header file timer640.h in the axon.c file ?
It should already be there.
What code version are you using? This doesn't work on earlier code versions.
-
Its in timer640.c
http://www.societyofrobots.com/axon/axon_function_list.shtml#pwm
Do i need to add the header file timer640.h in the axon.c file ?
It should already be there.
What code version are you using? This doesn't work on earlier code versions.
no admin, i tried adding the header file timer640.h and still i get the same error. I'm using version 1.08.
-
ok I'll look into it tonight
-
ok so it appears it got broken when the PWM file was entirely rewritten . . .
Until I fix it, just add this code at the top of control.c, right after the variables are called, and it should work. It compiled fine for me, but I didn't test to see if it worked.
#ifndef PWM10
// mega128 PWM bits
#define PWM10 WGM10
#define PWM11 WGM11
#endif
//OC1B pin B6 (attached to green LED)
void PWM_Init_timer1_LED(u08 bitRes)
{
// enable timer2 as 8,9,10bit PWM
if(bitRes == 9)
{ // 9bit mode
sbi(TCCR1A,PWM11);
cbi(TCCR1A,PWM10);
}
else if( bitRes == 10 )
{ // 10bit mode
sbi(TCCR1A,PWM11);
sbi(TCCR1A,PWM10);
}
else
{ // default 8bit mode
cbi(TCCR1A,PWM11);
sbi(TCCR1A,PWM10);
}
// clear output compare values
OCR1B = 0;
}
//on commands
void PWM_timer1_On_LED(void)
{
sbi(TCCR1A,COM1B1);
cbi(TCCR1A,COM1B0);
}
//off commands
void PWM_timer1_Off_LED(void)
{
cbi(TCCR1A,COM1B1);
cbi(TCCR1A,COM1B0);
}
void PWM_timer1_Set_LED(u16 pwmDuty)
{OCR1B = pwmDuty;}
-
thnx admin! It worked. ;D
Can you work on this pwm error as soon as possible? If u can, it would be nice ;)
-
thnx admin! It worked. ;D
Can you work on this pwm error as soon as possible? If u can, it would be nice ;)
Well, since this quick hack fixes it, its now a low priority bug fix.
I'll make sure it works correctly with the next code version release.