libpruio  0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
pruss_toggle.py File Reference

Example: PRUSS GPIO toggling measured speed. More...

Go to the source code of this file.

Functions

def pruss_toggle.load_firmware (IRam)
 Load firmware into PRUSS instruction ram. More...
 

Variables

 pruss_toggle.io = pruio_new(PRUIO_DEF_ACTIVE, 4, 0x98, 0)
 Create a ctypes pointer to the pruio structure.
 
 pruss_toggle.IO = io.contents
 The pointer dereferencing, using contents member.
 
int pruss_toggle.pru_num = 0
 The PRU subsystem we use.
 
 pruss_toggle.pru_iram = PRUSS0_PRU0_IRAM
 The instruction ram ID of PRU subsystem.
 
 pruss_toggle.pru_dram = PRUSS0_PRU0_DRAM
 The direct access ram ID of PRU subsystem.
 
 pruss_toggle.pru_intr = PRU0_ARM_INTERRUPT
 The interrupt we use.
 
 pruss_toggle.f = c_float(0)
 The measured frequency.
 
 pruss_toggle.d = c_float(0)
 The measured duty cycle.
 
 pruss_toggle.dram = pointer(c_uint32(0))
 The pointer to the PRU direct access ram.
 

Detailed Description

Example: PRUSS GPIO toggling measured speed.

This file contains an example for parallel usage of the other PRUSS. The firmware toggles a GPIO pin at reduced speed. (Maximum is 100 MHz pulse train, we add 4 NOOPs to reduce it to 20 MHz for better measurments.) Find a functional description in section pruss_toggle.

Licence: GPLv3, Copyright 2018-2023 by Thomas{ doT ]Freiherr[ At ]gmx[ DoT }net

Run by: python pruss_toggle.py

Since
0.6.4

Definition in file pruss_toggle.py.

Function Documentation

◆ load_firmware()

def pruss_toggle.load_firmware (   IRam)

Load firmware into PRUSS instruction ram.

Parameters
IRamThe IRam ID for the PRU to use
Returns
Zero on success, otherwise error raising

The instructions are compiled by command

pasm -V3 -c pruss_toggle.p

from source code (named pruss_toggle.p)

.origin 0
  LDI  r0, 0
  LBBO r1, r0, 0, 12 // load parameters in r1 (bitnumber), r2 (counter), r3 (interrupt)
  LDI  r0, 1
  LSL  r1, r0, r1.b0 // generate bit mask

start:
  LOOP finished, r2.w0
  XOR  r30, r30, r1  // togle output, max. 200 MHz toggling
  LDI  r0, 0         // NOOPs here, CAP is only 100 MHz
  LDI  r0, 0         // 1 + 4 x NOOP = 5 cycles
  LDI  r0, 0         // --> 40 MHz toggling frequency
  LDI  r0, 0         // --> 20 MHz pulse train
finished:

  MOV  r31.b0, r3.b0 // send notification to host
  HALT
  JMP start

Definition at line 48 of file pruss_toggle.py.