This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

am3517 pwm

in uboot  ,I configure as follow


 MUX_VAL(CP(MCSPI2_SIMO), (IEN  | PTD | DIS | M1)) 
 MUX_VAL(CP(MCSPI2_SOMI), (IEN  | PTD | DIS | M1))

i wrote a driver to genarate pwm at  timer_ptr9 and timer_ptr10,the details are as follow

static struct omap_dm_timer *timer_ptr9,*timer_ptr10;

void shp(void)
{
 timer_ptr9 = omap_dm_timer_request_specific(9);
 if(timer_ptr9 == NULL)
    {
  printk("gptimer test: No more gp timers available, bailing out\n");
  return -1;
 }

    omap_dm_timer_set_pwm(timer_ptr9,0,1,OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE);

 omap_dm_timer_set_source(timer_ptr9, OMAP_TIMER_SRC_SYS_CLK);

 omap_dm_timer_set_prescaler(timer_ptr9, 7); 
 
    omap_dm_timer_set_load(timer_ptr9, 1, 0xFFFFFFFE);

 omap_dm_timer_write_counter(timer_ptr9, 0xFFFFFFFE);
 
 omap_dm_timer_set_match(timer_ptr9, 1, 0xFFFFFFFE);
 
 omap_dm_timer_start(timer_ptr9);

}

void shd(void)
{
 timer_ptr10 = omap_dm_timer_request_specific(10);
 if(timer_ptr10 == NULL)
    {
  printk("gptimer test: No more gp timers available, bailing out\n");
  return -1;
 }

    omap_dm_timer_set_pwm(timer_ptr10,0,1,OMAP_TIMER_TRIGGER_OVERFLOW_AND_COMPARE);

 omap_dm_timer_set_source(timer_ptr10, OMAP_TIMER_SRC_SYS_CLK);

 omap_dm_timer_set_prescaler(timer_ptr10, 7);
 
    omap_dm_timer_set_load(timer_ptr10, 1, 0xFFFFFFFE);

 omap_dm_timer_write_counter(timer_ptr10, 0xFFFFFFFE);
 
 omap_dm_timer_set_match(timer_ptr10, 1, 0xFFFFFFFE);
 
 omap_dm_timer_start(timer_ptr10);

}

static ssize_t caiji_rd(struct file *file, char *buffer, size_t count, loff_t * offset)

unsigned short int *dbuf;
dbuf=kmalloc(2048*sizeof(unsigned short int), GFP_KERNEL);

  shp();
  shd();

omap_dm_timer_free(timer_ptr9);
omap_dm_timer_free(timer_ptr10);

  copy_to_user(buffer, (char*)dbuf, 4096);
  kfree(dbuf);
 return 0;

}

i also wrote a application program

       while(1)
{

 read(fd, buffer, 4096);
}

I can get pwm at corresponding pins,but    the relation of timer_ptr9 and  timer_ptr10 is not fixed ;another problem is how to know the pwm is high first or low first

anyone who could help me will be very appreciated !