2009-03-13 08:43:06     Timer in BF527.

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

2009-03-13 08:43:06     Timer in BF527.

Samuel Coelho (BRAZIL)

Message: 70951   


  Hi all.


  I'm using a BF527 Ezkit and uClinux 2008R1.5-RC3.


  I want to use a timer for generate a frequency of 32KHz.

  I read two topics (General Purpose Timers and Kernel Timers) in  Blackfin Linux Docs site, but did not understand right.

  I'm trying compile one kernel image with General Purpose Timers char device driver, but don't works.

  I have to write a driver for timer necessarily? How do I proceed?


  Someone already has used timer with BF527?


  Regards, Samuel.




2009-03-13 14:52:58     Re: Timer in BF527.

Mike Frysinger (UNITED STATES)

Message: 70966   


you'll have to provide more information than "dont works".  how exactly are you testing it and why do you think it isnt working ?




2009-03-14 10:36:33     Re: Timer in BF527.

Phil Wilshire (UNITED STATES)

Message: 70981   


Yes some more info would help


but I have this one fixed I think


in linux-2.6.x/drivers/char/bfin_simple_timer.c


change the line


#if defined(BF533_FAMILY) || defined(BF537_FAMILY)




#if defined(BF533_FAMILY) || defined(BF537_FAMILY) || defined(BF527_FAMILY)




enable BFIN_SIMPLE_TIMER in the kernel config




I have also attached some simple test code


cd uClinux-dist-2008R1.5-RC3


tar xvzf simple_timer_test.tar.gz


  this creates user/simple_timer and puts some files in it


  use the following to build it


make user/simple_timer_only


copy to the target ( use your target_ip)


rcp user/simple_timer/simple_timer root@<target_ip>:/bin


run the simple timer in the background


root:/> /var/simple_timer &                                                   


root:t> imer_open: device(4) opened                                           

timer_ioctl TIMER_SET_PERIOD: arg=31, period=4068, width=2034                 

Set timer period res = 0                                                      

Start timer res = 0                                                           

press CTRL-C to stop this        


Then look at the system running




root:/> cat /proc/bfin_simple_timer                                           

timer  0 isr count: 0                                                         

timer  1 isr count: 0                                                         

timer  2 isr count: 0                                                         

timer  3 isr count: 0                                                         

timer  4 isr count: 836432                                                    

timer  5 isr count: 0                                                         

timer  6 isr count: 0                                                         

timer  7 isr count: 0    




Stop the program with the kill command


root:/> kill 142                                                              

timer_close: device(4) closed                                                 

142: Terminated                                                               




Hope this helps


   Phil Wilshire








2009-03-14 10:40:34     Re: Timer in BF527.

Mike Frysinger (UNITED STATES)

Message: 70982   


ok, i can see the branch being broken, but this should be fixed cleanly in trunk now ...




2009-03-18 08:42:40     Re: Timer in BF527.

Samuel Coelho (BRAZIL)

Message: 71203   


Hi all.


The timer works. Thanks for your help.


But now I have a doubt.



I need use a timer to generate a frequency of 32KHz for use one ADC over SPI.

I wrote a code in VisualDSP to do this. I handle a timer interrupt to read SPI.

With uClinux I can't handled interrupt in user space, only in Kernel space?

I need write a driver to handle timer interrupt and read SPI? This is correct? How the best way to solve my case?


Regards, Samuel.





2009-03-18 14:36:58     Re: Timer in BF527.

Mike Frysinger (UNITED STATES)

Message: 71218   


only the kernel can handle an interrupt