Atmega8 + FreeRTOS + PWM
Posted by misiekg on November 5, 2009
Hello,
I have problem with cooperating of those 3 as I wrote in the title. I Set up FreeRTOS with 2 tasks(one blinking diode and sending data to another task, second getting data and showing on lcd).
It is in small robot and I need in the future get ADC readings, proceed them and move engines using PWM.
The problem is that when I use PWM everything goes wrong. Task stop communicating and I get strange captions on LCD. If I switch off PWM, when task send/get data one engine is movin a little... I can post my code here if it would help.
Thank you very much in advance for help.
RE: Atmega8 + FreeRTOS + PWM
Posted by
MEdwards on November 5, 2009
Sounds like the pwm code is bad, or using it in a task is causing some sort of corruption (stack overflow being most likely). Is the PWM using an interrupt or is it completely autonomous?
RE: Atmega8 + FreeRTOS + PWM
Posted by misiekg on November 6, 2009
Here is my pwm code. I use first init pwm in main, and then setPwm():
void initPwm ()
{
TCNT1 = 0;
OCR1A = 0;
OCR1B = 0;
TCCR1A = _BV(COM1A1)| _BV(COM1B1)| _BV(WGM11)| _BV(WGM10);
TCCR1B = _BV(CS10);
}
void setPwm(int le, int re)
{
if ( le < 0)
le = 0;
if (le > 800)
le = 800;
if (re < 0)
re = 0;
if (re >800)
re = 800;
OCR1A = re;
OCR1B = le;
}
Is FreeRTOS using timer? Maybe it uses my timer1, which I use for PWM?
Thanks for your reply.
RE: Atmega8 + FreeRTOS + PWM
Posted by misiekg on November 6, 2009
Even if I don't initialize PWM and don't set values it sensds signal to the pin connected to bridge while comunicating tasks.