FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [March 2010 Threads] How to PWM(50Hz) using FreeRTOSPosted by SnEAky on March 18, 2010 Hello,
How is it possible to control a servo motor using a 50Hz PWM. It's for a LPCXpresso 1343. I've managed to port the FreeRTOS to 1343, but I have no idea how to use the timers.
Here is the code for a PWM init that does work without FreeRTOS:
void PWM_init(void){ /** Timer 16 / PWM Settings **/ // PWM output: 16bit_timer1
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<8); // Enable clock to timer 1 LPC_IOCON->PIO1_9 &= ~0x1F; // - remove bits 0,1 & 2 and pull resistors LPC_IOCON->PIO1_9 |= 0x01; /* Timer1_16 MAT0 */ //- set bit 1 LPC_IOCON->PIO1_10 &= ~0x1F;// - remove bits 0,1 & 2 and pull resistors LPC_IOCON->PIO1_10 |= 0x02;/* Timer1_16 MAT1 */
LPC_TMR16B1->MCR = 0x0400; /* Reset at MR3*/ LPC_TMR16B1->PR = 50;/* set prescaler 50*28800 = 72MHz */ LPC_TMR16B1->MR0 = 28800-2880; /* Match register 0 - pulse width LPC_TMR16B1->MR1 = 7000; /* Match register 1 - no PWM - toggle test */ LPC_TMR16B1->MR3 = 28800;//14399; /* Match register 3 - cycle length */ LPC_TMR16B1->EMR = 0xC2; /* External Match register Settings for PWM channel have no effect.*/ LPC_TMR16B1->PWMC = 0x01; /* PWMC register -MAT0 is PWM. */ GPIOSetDir( 1, 9, 0 ); // Set as output GPIOSetDir( 1, 10, 1 ); // set as output LPC_TMR16B1->TCR = 1; // Enable timer 1 }
I want this code to work in FreeRTOS, but I have no idea how.
Can anyone help me ?
- SnEAky
RE: How to PWM(50Hz) using FreeRTOSPosted by Dave on March 18, 2010 First get it working without FreeRTOS, then build up the application around it.
RE: How to PWM(50Hz) using FreeRTOSPosted by SnEAky on March 18, 2010 It is already working without FreeRTOS like i said in my first post. I just have no idea how to make this work in FreeRTOS. I've put the init in setuphardware(); and i call that function in the main. Next I start a task that will set the pulse width, but for some reason nothing happens, the output is just a logical '1' and nothing happens.
Any idea?
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|