Generate clock on timer7 (P8_8)pin of beaglebone.

Hello…
I am first time work on beaglebone.I want to generate Clock of 3Khz on timer7 (P8_8)pin og beaglebone.
here is my code.

import Adafruit_BBIO.GPIO as GPIO
import time
outpin=“P8_8”
GPIO.setup(outpin,GPIO.OUT)
GPIO.setclock(outpin,3000)
while True:
GPIO.output(outpin,GPIO.HIGH)
time.sleep(2)
GPIO.output(outpin,GPIO.LOW)
time.sleep(2)

On Mon, 28 Jan 2019 01:27:39 -0800 (PST),
sayalikutwal07@gmail.com declaimed the
following:

Hello..
    I am first time work on beaglebone.I want to generate Clock of 3Khz on
timer7 (P8_8)pin og beaglebone.
here is my code.

import Adafruit_BBIO.GPIO as GPIO
import time
outpin="P8_8"
GPIO.setup(outpin,GPIO.OUT)
GPIO.setclock(outpin,3000)
while True:
     GPIO.output(outpin,GPIO.HIGH)
     time.sleep(2)
     GPIO.output(outpin,GPIO.LOW)
     time.sleep(2)
-------------------------------------------------------------------------------------
It gives error..
GPIO.setclock(outpin,3000)
AttributeError: 'module' object has no attribute 'setclock'

Please correct me..

  Well, where did you find any documentation about a .setclock()
function? It doesn't exist in
GPIO — General Purpose I/O interface — Adafruit-BBIO documentation so
take it out.

  Furthermore, your while loop takes four seconds to execute -- that
equates to a frequency of 0.25Hz. Generating a 3kHz square wave would
require time.sleep(0.000166666666) -- presuming the OS clock allows for
sleeps that small (note: you will also be affected by any OS pre-emption of
your program). [Total loop time 0.000333333]

  Perhaps you really want to be using the PWM function
https://adafruit-beaglebone-io-python.readthedocs.io/en/latest/PWM.html

Just use the BB-PWM-TIMER-P8.08.dts overlay:

https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-PWM-TIMER-P8.08.dts

PS, to hit your clock, make sure to properly set teh prescaler:

https://github.com/beagleboard/bb.org-overlays/blob/master/src/arm/BB-PWM-TIMER-P8.08.dts#L47

Regards,

How to set the function setclock for timer.

Hello.
I want the step by step process to generate clock on P8_8 pin of beaglebone .
and require python code to for the same .The step by step process to set prescaler.

On Tue, 29 Jan 2019 11:46:28 +0530, sayali kutwal
<sayalikutwal07@gmail.com> declaimed the
following:

How to set the function setclock for timer.

  There is NO setclock function in Adafruit_BBIO. A Google search doesn't
find ANY setclock function for BBB.

  The closest I've found is for setting SPI
https://groups.google.com/forum/#!msg/beagleboard/x6VjN_q00c4/UXRFmrYyITQJ

  Timers appear to be set up during boot using the device tree
https://www.element14.com/community/thread/34045/l/enabling-timer4-output-on-beaglebone-black?displayFullThread=true

  The possible alternative (I've not dug up the Technical Reference
Manual) might require mmap'ing to the timer control registers, and writing
the needed values to it. That assumes mmap can be set to go to hardware
addresses and not virtual addresses.

On Tue, 29 Jan 2019 11:50:23 +0530, sayali kutwal
<sayalikutwal07@gmail.com> declaimed the
following:

Hello.
  I want the step by step process to generate clock on P8_8 pin of
beaglebone .
and require python code to for the same .The step by step process to set
prescaler.

  Chapter 20 of
https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=2ahUKEwjEwdvoyJPgAhUKUa0KHSqvCSsQFjAAegQIChAC&url=https%3A%2F%2Fwww.ti.com%2Flit%2Fug%2Fspruh73p%2Fspruh73p.pdf&usg=AOvVaw1YMRpIKtzhhNT5QoOwIAZ2

Dennis
I think he wants you to code his college assignment for him and he doesn’t wanna read the TRM.
They used to give code examples in TRM today’s future engineers I’m getting scared😊

On Tue, 29 Jan 2019 18:55:49 +0000 (UTC), "'Mark Lazarewicz' via
BeagleBoard" <beagleboard@googlegroups.com>
declaimed the following:

DennisI think he wants you to code his college assignment for him and he doesn't wanna read the TRM.They used to give code examples in TRM today's future engineers I'm getting scared?

  No doubt -- but that I don't provide (I haven't read enough of the TRM
to even attempt this using C).

  My normal response is "how would you do that in C?" and then maybe
assist in porting the C to Python.

Sorry Dennis I guess I’m not very tactful. I’ll try and rephrase.
Doesn’t programming any internal microprocessor registers start with the TRM programming in any language? I can’t comprehend not reading the TRM then using a bunch of library functions in some code I found without understanding what the code is doing. I guess if it works and you don’t care about how it works that’s fine. I’ve always been fascinated with the details of the registers.these newer chips are quite complex and reading the relavent chapter takes some time and can be daunting but I always figured that was how you really understood the low level

Hello.
It’s not my collage assignment. I just want to learn the beaglebone for curiosity. So i want to generate the clock on pin P8_8 (timer7) beaglebone.
For this i write python code…

import Adafruit_BBIO.GPIO as GPIO
import time
outpin=“P8_8”
GPIO.setup(outpin,GPIO.OUT)
GPIO.setclock(outpin,3000)
while True:
GPIO.output(outpin,GPIO.HIGH)
time.sleep(2)
GPIO.output(outpin,GPIO.LOW)

time.sleep(2)

Hello Sayali

My one experience with Python was some HWIL I was modifying for NASA Satellite to test my bootloader written in C. I’m a C programmer I’m not familiar with this library where did you get this
time.sleep(2) statement?

Maybe you are not importing the correct objects. If SLEEP exists you need to find how to pull it in if it doesn’t exist write your own. I’m sure you can see this sleep is used to generate a square wave of a certain frequency you can see on the the o scope on the pin.Sleep is going to somehow convert the 2 into seconds or milliseconds etc and put into a processor register of a timer for that so you might need to study TRM.
If I was a professor teaching microprocessors Id leave that to the student to complete to see if he’s got the ambition to dig deep and understand the chip.
Getting some code to compile on a target sounds more like some programming exercise. If you want to learn embedded software engineer not be a programmer learning to write such code will be helpful and require read TRM.

Good Luck

On Wed, 30 Jan 2019 10:04:21 +0530, sayali kutwal
<sayalikutwal07@gmail.com> declaimed the
following:

Hello.
    It's not my collage assignment. I just want to learn the beaglebone
for curiosity. So i want to generate the clock on pin P8_8 (timer7)
beaglebone.
For this i write python code...

import Adafruit_BBIO.GPIO as GPIO
import time
outpin="P8_8"
GPIO.setup(outpin,GPIO.OUT)
GPIO.setclock(outpin,3000)
while True:
GPIO.output(outpin,GPIO.HIGH)
time.sleep(2)
GPIO.output(outpin,GPIO.LOW)
time.sleep(2)
----------------------------------------------
But there is not any library for timer.so i am not getting anything.
after searching i find the term DMTimer to generate clock for beaglebone
but i dont know how to do it.
so please guide me step by step.

  STEP ONE: READ the TRM section on timers

  Step Two: determine how you would access the settings using a low-level
language (C, assembler)

  Step Three: port that code to Python -- which might mean writing a
C-language extension library that you can import (read the Extending Python
manual) as direct hardware access may not be possible in pure Python.

  Since no one has provided a quick solution, the odds are very good that
no one reading this thread has ever done what you are asking... And that
means ANY OF US would have to do the above three steps to answer you. And
since none of us (except you) has the interest, that leaves it on you to do
the needed research.

Using GPIO control only:

Hi sayalik!

Your task gets very simple when you drop Adafruit library and use libpruio instead. The code

`
#!/usr/bin/python

\file

\brief Example: set 3 kHz timer on P8_08.

I forgot to mention that you need the language binding in you project folder. Befor running the code also execute

`
cd <your_project_folder>

cp -r /usr/share/doc/python-pruio/examples/libpruio .

`

Find further details in the on-line docs.

One more notice:

After installing libpruio (code sequence in my first post) you have to reboot in order to get ride of the cape-universal stuff.

Hello.
Thank you for your great support.Its help me lot.