2008-09-08 00:01:44 gptimers
John Doe (UNITED STATES)
Message: 61768
I am looking to use timers to generate when a pin should go high. I have read the hardware schematics, the manual, and the gptimer page. the manual and the gptimer page say to reference the hw schematic but the schematic doesnt have anything about portf. I guess my questions are can I access these timers from userspace and how do I? I have enabled the timers in the kernel but unlike the gpios they don't show up in /dev. BTW mike you have been awesome in pointing me in the right directions.
QuoteReplyEditDelete
2008-09-08 00:14:53 Re: gptimers
Mike Frysinger (UNITED STATES)
Message: 61769
the PORT stuff is software only so it isnt going to be in any schematic. the gptimers page in the wiki also does not say anywhere to read a schematic ... it says to read the HRM.
like any other hardware, if you want to access it from userspace, you need a device driver. there is a sample one already in the char directory. did you enable the kernel API or the char device driver ?
QuoteReplyEditDelete
2008-09-08 00:19:48 Re: gptimers
John Doe (UNITED STATES)
Message: 61770
i enabled the char device driver and I figured out that i needed the simple_gpio_timer built in to the kernel as well. Now I can see all the timers in /dev and have seen the simple_timer under proc, but where can i find documentation on how to read the timers, set them etc. I can't find any information anywhere.
QuoteReplyEditDelete
2008-09-08 17:03:47 Re: gptimers
Mike Frysinger (UNITED STATES)
Message: 61799
there is no "simple_gpio_timer" driver. the "bfin_simple_timer" driver is completely independent of the "simple-gpio" driver. there is no documentation on the bfin_simple_timer driver at the moment other than the source code. it is a simple driver, so it shouldnt be hard to digest.
QuoteReplyEditDelete
2008-09-09 17:47:43 Re: gptimers
John Doe (UNITED STATES)
Message: 61849
so bfin_simple_timer.c is a kernel file correct? so then i can use read() and write() to interface with each timer, correct? if I am correct so far this is where i get confused... what do i send with read, write and open? so if im not correct i am totally lost... and a pointer to the right file would be awesome.
QuoteReplyEditDelete
2008-09-09 19:00:41 Re: gptimers
Mike Frysinger (UNITED STATES)
Message: 61851
i think you need to start simpler. please get the LDD3 book and read some of the intro chapters:
http://docs.blackfin.uclinux.org/doku.php?id=references_and_pointers
QuoteReplyEditDelete
2008-09-11 13:27:46 Re: gptimers
John Doe (UNITED STATES)
Message: 62001
Thank you again mike for your patience. I do have the book now, can you tell me the most important chapters to read? I have already read chp 9 and am going to read chapter 10. I am limited on time, but we have ordered two more 537's that I just got today and hopefully the software on there answers a lot of my questions.The one were using right now was givin to us to use by one of our teachers. Like I said earlier our team is limited on time, I don't want code to use because I don't feel right using other peoples code, I dont like to explain what I dont know is going on. So far chapter 9 has answered questions on kernel space and userspace.
QuoteReplyEditDelete
2008-09-11 14:49:29 Re: gptimers
Robin Getz (UNITED STATES)
Message: 62004
Dustin:
>I don't want code to use because I don't feel right using other peoples code,
Umm - isn't this the whole point of open source? Participatiants in open source do it as as a means to drive innovation, ultimately creating and deploying better quality, higher reliability, more flexible, lower cost products - all based on other people's code.
Wanting to understand how things work is great - but once you understand it, there is no shame in borrowing the right peices from pre-existing projects.
-Robin
QuoteReplyEditDelete
2008-09-11 15:15:58 Re: gptimers
Mike Frysinger (UNITED STATES)
Message: 62007
if you're working on a char driver, then chapter 3 is a good intro to that
otherwise, you should make sure to read chapter 1 and bits of chapter 2 as they covers basic paradigms
and as Robin said, this is how open source works: you take a code base that is similar to what you need to get done and you use that as a starting point
QuoteReplyEditDelete
2008-09-15 14:34:56 Re: gptimers
John Doe (UNITED STATES)
Message: 62185
How would I use nop within a function and does it only use 1 cycle?
__asm__ ("nop;");
QuoteReplyEditDelete
2008-09-15 14:41:32 Re: gptimers
Bernd Schmidt (GERMANY)
Message: 62187
Why would you want to do such a thing?
QuoteReplyEditDelete
2008-09-16 12:30:59 Re: gptimers
John Doe (UNITED STATES)
Message: 62257
becuase if I know the speed of the processor then I know how much time it takes to do a cycle, and from that I could make a quick timer in my software untill I understand how to access the timers
QuoteReplyEditDelete
2008-09-16 13:54:26 Re: gptimers
Mike Frysinger (UNITED STATES)
Message: 62260
that's just silly. if you want a delay, then use a delay function that the kernel already provides.
QuoteReplyEditDelete
2008-11-17 02:00:07 Re: gptimers
John Doe (UNITED STATES)
Message: 65356
Im a little stuck right now with the timers. I have looked over bfin_simpler_timer c and h. I am not exactly sure how to communicate with the kernel and these timers. With the gpio's it was pretty simple once I saw it. After reading the header file I assumed that I wrote specific values to the files to start the timers and that I could see their values under /proc/bfin_simple_timer. Forgive me for frustrating anyone before. What I need the timer for is to pull a value from when I send a pulse and then receive a pulse back. So I dont really need any interupts and I am trying to do this all from userspace. The resolution needs to be as finite as the blackfin can be.
QuoteReplyEditDelete
2008-11-17 12:48:41 Re: gptimers
Mike Frysinger (UNITED STATES)
Message: 65385
the interface is documented at the top of the driver in the large comment block
QuoteReplyEditDelete
2008-11-17 13:15:23 Re: gptimers
John Doe (UNITED STATES)
Message: 65386
Mike again thank you for being patient,
Here is some code that I have written in a c file:
if(fprintf(t_timer,"2,2") != 3) //error output if unsuccessfull else set up timer
fsync(t_timer);
if(fprintf(t_timer,"6") != 1) //error output if unsuccessfull else start timer
fsync(t_timer);
if(fprintf(t_timer,"8") != 1)//error output if unseccessfull else stop timer
fsync(t_timer);
I am using fopen and such to write to the files, I have not tried using fcntl.h and just open to work with the files, which is the way that I have had success with the gpio's. I will try using open and fcntl instead and post back. If anyone sees any problem besides using fprintf please let me know.
QuoteReplyEditDelete
2008-11-17 13:20:22 Re: gptimers
Mike Frysinger (UNITED STATES)
Message: 65387
the comment block says use ioctl's to communicate
if you look in the driver at the fops structure, you'll see there is no read/write function defined. so anything you read or write to the driver is simply ignored.
i dont know why/how you'd use fcntl ... afaik, fcntl never goes to a char device driver
QuoteReplyEditDelete
2008-11-17 13:24:22 Re: gptimers
John Doe (UNITED STATES)
Message: 65388
So i need to write a kernel module for it?
QuoteReplyEditDelete
2008-11-17 13:29:01 Re: gptimers
Mike Frysinger (UNITED STATES)
Message: 65389
if the existing simple driver is not enough for your needs, you will need to write your own driver or extend the existing one
QuoteReplyEditDelete
2008-11-17 14:14:11 Re: gptimers
John Doe (UNITED STATES)
Message: 65390
ok so to work with this i need to open the file normally like im going to write to it then use int returnVal = ioctl(fd,6); to start it?
QuoteReplyEditDelete
2008-11-17 14:41:02 Re: gptimers
Mike Frysinger (UNITED STATES)
Message: 65391
if you arent familiar with ioctls, please review this:
http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:ioctls
QuoteReplyEditDelete
2008-11-18 13:39:24 Re: gptimers
John Doe (UNITED STATES)
Message: 65452
thank you mike you are awesome. if i have any other questions i will post again