Calculate frequencey and pulse width?

Liste des GroupesRevenir à cs raspberry-pi 
Sujet : Calculate frequencey and pulse width?
De : jansencomplex (at) *nospam* gmail.com (Samson)
Groupes : comp.sys.raspberry-pi
Date : 01. Nov 2024, 07:19:07
Autres entêtes
Message-ID : <loja6sF6unbU1@mid.individual.net>
User-Agent : Mozilla Thunderbird
Hi, i have this code hos do i  calculate the frquency  and pulse width?

from machine import Pin
from rp2 import PIO, StateMachine, asm_pio
import time

led = Pin("LED", Pin.OUT, value=0)

@asm_pio(set_init=PIO.OUT_LOW)
def square():
    # Cycles: 1 + 1 + 6 + 32 * (30 + 1) = 1000
    irq(rel(0))
    set(pins, 1)
    set(x, 31)                  [5]
    label("delay_high")
    nop()                       [5]
    jmp(x_dec, "delay_high")

    # Cycles: 1 + 7 + 32 * (30 + 1) = 1000
    set(pins, 0)
    set(x, 31)                  [5]
    label("delay_low")
    nop()                       [1]
    jmp(x_dec, "delay_low")

sm = StateMachine(0, square, freq=2000, set_base=Pin(0))

sm.irq(lambda p: led.toggle())

sm.active(1)



Date Sujet#  Auteur
1 Nov 24 * Calculate frequencey and pulse width?3Samson
1 Nov 24 `* Re: Calculate frequencey and pulse width?2Lawrence D'Oliveiro
2 Nov 24  `- Re: Calculate frequencey and pulse width?1Samson

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal