2010-04-09 10:37:32     Problem with timer on BF536 (works on BF537 EZ-KIT Lite)

Document created by Aaronwu Employee on Aug 21, 2013
Version 1Show Document
  • View in full screen mode

2010-04-09 10:37:32     Problem with timer on BF536 (works on BF537 EZ-KIT Lite)

Lorenzo Mariani (ITALY)

Message: 88262   

 

Hi everybody,

i'm doing some tests with the timer of bf536 (revision 0.3) and I can't use the PULSE_HI function nor the TOGGLE_HI function on the timer2 in PWM_OUT mode

 

I tried to put the same code on the BF537 EZ-KIT Lite and it works fine, so I don't know how it doesn't work on the bf536

 

I hope you can help me to resolve this problem. Thanks in advance for your help!

 

here is my code:

 

int init_module(void)

{

    int err;

 

    printk ("Loading IRQ module..\n");

 

    //WR=1 CE=0

    RTC_CS2 = 0xBF;

    //WR=1 CE=1

    RTC_CS2 = 0xFF;

   

       

   

    //enable PORTF[7] peripheral function

    *(uint16_t *) PORTF_FER |= 0x0080;

    *(uint16_t *) PORTF_FER &= ~(0x0100);

    //PORTF[7]-[8] are outputs

    *(uint16_t *) PORTFIO_DIR |= 0x0180;

 

   

    err = request_irq (IRQ_TIMER2, interrupt, IRQF_DISABLED, "TIMER2", NULL);

/*    if (err) {

        printk(KERN_INFO "IRQ: can't get assigned irq %i\n", IRQ_TIMER2);

        return -1;

    }*/

 

    *(uint16_t *) TIMER_DISABLE |=     (1<<2);    // Disable TIMER2

 

    while(( *(uint32_t *) TIMER_STATUS & (1<<14)) != 0) ;

 

    *(uint32_t *) TIMER2_PERIOD  =  20000; // period = 200 us

    *(uint32_t *) TIMER2_WIDTH   =   2000; // duty_cicle = 20 us

 

    *(uint16_t *) TIMER2_CONFIG |=  (0x01);    // Enable PWM_OUT mode

    *(uint16_t *) TIMER2_CONFIG &= ~(1<<2);    // Negative action pulse

//    *(uint16_t *) TIMER2_CONFIG |=  (1<<2);    // Positive action pulse

    *(uint16_t *) TIMER2_CONFIG |=  (1<<3);    // Enable periodic count

    *(uint16_t *) TIMER2_CONFIG |=  (1<<4);    // Enable TIMER2 interrupt

    *(uint16_t *) TIMER2_CONFIG |=  (1<<5);    // TIN_SEL

    *(uint16_t *) TIMER2_CONFIG &= ~(1<<6);    // Enable PWM output

    *(uint16_t *) TIMER2_CONFIG &= ~(1<<7);    // Use system clock SCLK

    *(uint16_t *) TIMER2_CONFIG |=  (1<<8);    // The state of PULSE_HI alternates each period

//    *(uint16_t *) TIMER2_CONFIG &= ~(1<<8); // The state of PULSE_HI is fix

    *(uint16_t *) TIMER2_CONFIG |=  (1<<9);    // Enable EMU_RUN

 

    *(uint16_t *) TIMER_ENABLE  |=  (1<<2);    // Enable TIMER2

 

 

    printk("TIMER2_CONFIG: 0x%04x\n", *(uint16_t *) TIMER2_CONFIG);

    return 0;

}

TranslateQuoteReplyEditDelete

 

 

2010-04-09 10:38:43     Re: Problem with timer on BF536 (works on BF537 EZ-KIT Lite)

Lorenzo Mariani (ITALY)

Message: 88263   

 

sorry, I forgot to add the file

 

 

irq_test.c

TranslateQuoteReplyEditDelete

 

 

2010-04-09 12:40:22     Re: Problem with timer on BF536 (works on BF537 EZ-KIT Lite)

Mike Frysinger (UNITED STATES)

Message: 88265   

 

this is the hardware forum, not linux forum.  ive moved your post this time, but please select the right one in the future.

 

why dont you use the gptimer API instead of programming registers yourself ?

  docs.blackfin.uclinux.org/doku.php?id=gptimers

 

you absolutely should not be touching the PORTMUX MMRs under Linux.  that is not supported and you're on your own if you continue that path.  that's what the peripheral_request() and such functions are for.

QuoteReplyEditDelete

 

 

2010-04-13 02:52:13     Re: Problem with timer on BF536 (works on BF537 EZ-KIT Lite)

Lorenzo Mariani (ITALY)

Message: 88354   

 

this is the hardware forum, not linux forum.  ive moved your post this time, but please select the right one in the future.

 

why dont you use the gptimer API instead of programming registers yourself ?

  docs.blackfin.uclinux.org/doku.php?id=gptimers

 

you absolutely should not be touching the PORTMUX MMRs under Linux.  that is not supported and you're on your own if you continue that path.  that's what the peripheral_request() and such functions are for.

 

---

 

Sorry, I thought it is a hardware problem because the same code has different results on different uc, anyway, thank for your correction.

 

many thanks for your suggestions, i'm going to try them.

Attachments

Outcomes