How can I generate PWM on Beagleboard xm?

Hi there.

Now i’m figuring out how to generate PWM on Beagleboard xm.

And I’m following this post.

http://thoughtshubham.blogspot.kr/2010/04/pwm-generation-in-beagleboard.html?showComment=1383826424966#c2949800981327921200

So, In this code I have some question.

main code is like this and if you wonder what is the waveform.c file, you can easily find in the post over there.

#include < stdio.h >
#include < string.h >
#include < stdlib.h >
#include < pthread.h >
#include < time.h >
#include < fcntl.h >
#include < sys types.h="" >
#include < sys stat.h="" >
#include"waveform.c"
time_info pwm_times;
time_info pwm_times2;
int main()
{
int i=0,j,k,l;
pthread_t threadid;
pthread_t threadid2;
pwm_times.time_h=0;
pwm_times.time_l=0;
pwm_times2.time_h=0;
pwm_times2.time_l=0;
pthread_create(&threadid,NULL,pwm,(void*)&pwm_times);
pthread_create(&threadid2,NULL,pwm2,(void*)&pwm_times2);
while(1)
{
for(l=0;l<1000;l++)
{
// Your main code runs here
for(j=0;j<1000;j++)
{
for(i=0;i<1000;i++)
{}
}
// Your code ends here
// Update values of PWM
pwm_times.time_h=(300000+l1000);
pwm_times.time_l=(300000-l
1000);
pwm_times2.time_h=(600000-l1000);
pwm_times2.time_l=(600000+l
1000);
}
}
}

So, my question is How can I use this code in the for loop?

I’m the newbie so I coudn’t figure out how modify my code.

I need just a simple exmaple of using this code for running servo motor.

Anyone who had used this source please help me.

thanks a lot!