SetPin(GPnn), FIN query


Author Message
carlschneider
Senior Member

Joined: 04/08/2023
Location: South Africa
Posts: 158
Posted: 03:03pm 26 Aug 2023      

Hi Volhout

Thank you for the PIO solution.This is not something I have tried yet.

I have captured the PIO programming as you provided in the Pico running at 264MHz.


'Frequency pin test
If MM.Info(ip address) = "0.0.0.0" Then
Print "Failure to connect to the Internet - Restart"
CPU restart
EndIf
'
'
Print MM.Info(ip address)

On ERROR SKIP 5
WEB NTP -6 'Saskatoon
If MM.Errno Then WEB NTP -6
If MM.Errno Then WEB NTP -6
If MM.Errno Then Print "Failure to connect to the NTP Server" : CPU RESTART

Target=50.01
SetPin GP5, PWM2B
PWM 2, Target,, 50

'PIO frequency counter for PICOMITE MMBasic measuring period time

'this is a PIO program
Dim a%(7)=(&h008400C5A029E020,&hE0408000A0CA0042,&h00C9008B004AA04A,&h8000A0C9,
0,0,0,0)

'PIO configuration
f=264e6                     '264MHz PIO execution speed
e=Pio(execctrl gp6,0,31)    'use gp0 for PIN...select the input pin

'program pio1 and start
PIO program 1,a%()
PIO init machine 1,0,f,0,e
PIO start 1,0    

'pio fifo register for reading information from PIO
Dim x%(4)

'read the PIO time counted and convert to frequency
Do
PIO read 1,0,5,x%()           'read 5 count values, fifo + most recent
period = x%(4) + 4            'counts measured + instructions PIO setup time
Print f/(3*period);" Hz"      'convert counts to Hz and print
Pause 1000
Loop While Inkey$=""

End


Unfortunately there appears to be an error

> RUN
172.16.1.67
ntp address 209.115.181.107
got ntp response: 26/08/2023 08:55:40
[38] PIO program 1,a%()
Error : 1 is invalid (valid is 0 to 0)
> option list
WebMite MMBasic Version 5.07.07
OPTION COLOURCODE ON
OPTION CPUSPEED (KHz) 264000
OPTION DISPLAY 41, 140
OPTION WIFI Actiontec1177, **********
OPTION TCP SERVER PORT 80
OPTION TELNET CONSOLE ON

I checked in the manual and the example provides
PIO program 1, a%

So at this stage I'm fumbling around in the dark unfortunately.

Thank you for your assistance.