Search found 66 matches

by rkompass
Fri Aug 19, 2022 8:25 am
Forum: Raspberry Pi microcontroller boards
Topic: How to load 32 bit constant from assembler with @micropython.asm_thumb
Replies: 6
Views: 24094

Re: How to load 32 bit constant from assembler with @micropython.asm_thumb

I successfully used the following to load a 32 bit word in to r5: data(2, 0x4d00) # ldr r5, [pc, #0] load r5 with data following the branch (0x4e00: ldr r6, [pc, #0]) b(HERE0) data(4, 0x1b8d72e4) # r5 = 0b00011011100011010111001011100100, the state table in 32 bits label(HERE0) This is the way viper...
by rkompass
Thu Jul 28, 2022 6:19 pm
Forum: General Discussion and Questions
Topic: Using machine Pin class no way to get pin number or channel when running on Pi Pico?
Replies: 7
Views: 9980

Re: Using machine Pin class no way to get pin number or channel when running on Pi Pico?

You are right: I flashed the nightly build and now pin('LED') is possible even on RPI Pico! Nice.
by rkompass
Thu Jul 28, 2022 6:12 pm
Forum: General Discussion and Questions
Topic: Using machine Pin class no way to get pin number or channel when running on Pi Pico?
Replies: 7
Views: 9980

Re: Using machine Pin class no way to get pin number or channel when running on Pi Pico?

Hey Scruss, Pin('LED') works for me on Teensy 4.1 and this name is revealed indeed if I look it up in Pin.board.__dict__.items() like posted above. In RPI Pico I don't find Pin.board or Pin.cpu (those nasty inconsistencies in different ports .., is there something similar at least?). So the only way...
by rkompass
Thu Jul 28, 2022 4:16 pm
Forum: General Discussion and Questions
Topic: Using machine Pin class no way to get pin number or channel when running on Pi Pico?
Replies: 7
Views: 9980

Re: Using machine Pin class no way to get pin number or channel when running on Pi Pico?

Hello Jibun, I'm not sure I understood your question. Perhaps this is what you are looking for: from machine import Pin pin1 = Pin('A12', Pin.OUT) print(list((name for name, code in Pin.board.__dict__.items() if code == pin1))) # or print(list((name for name, code in Pin.cpu.__dict__.items() if code...
by rkompass
Tue Jul 26, 2022 8:48 pm
Forum: General Discussion and Questions
Topic: Using machine Pin class no way to get pin number or channel when running on Pi Pico?
Replies: 7
Views: 9980

Re: Using machine Pin class no way to get pin number or channel when running on Pi Pico?

you could try:

Code: Select all

baddr=bytes(array('O', [pin]))
mem32[int.from_bytes(baddr, 'little')+4]
but I'm not sure this is "Future-safe".
It works here for RPi2040.
by rkompass
Tue Jul 26, 2022 8:38 pm
Forum: General Discussion and Questions
Topic: howto get itemsize of an array
Replies: 2
Views: 3902

Re: howto get itemsize of an array

Thank you Scruss. Didn't know of this solution. It's nice but will not work in my case unfortunately, as the array is possibly very large indeed. I currently have: def array_dsize(arr): sizes = {'b': 0, 'B': 0, 'h':1, 'H':1, 'i':2, 'I':2, 'l':2, 'L':2, 'q':3, 'Q':3, 'f':2, 'd':3} baddr=bytes(array('...
by rkompass
Tue Jul 26, 2022 3:20 pm
Forum: General Discussion and Questions
Topic: howto get itemsize of an array
Replies: 2
Views: 3902

howto get itemsize of an array

Hello, I have an array like arr: from array import array arr = array('b', (2,3,4,0)) Now only having arr, how can I get the itemsize of arr, which in this case is 1? In Python 3.10 I would use arr.itemsize Is there another way than str(arr) and extracting the code form the string "array('b', [2, 3, ...
by rkompass
Mon Jul 25, 2022 11:39 am
Forum: Raspberry Pi microcontroller boards
Topic: PIO program to determine minimum, maximum and mean of pulses
Replies: 0
Views: 159905

PIO program to determine minimum, maximum and mean of pulses

For the problem reported in https://forum.micropython.org/viewtopic.php?f=6&t=12721 I wrote a class that employs 3 PIO state machines to determine minimum, maximum, count and mean of a series of pulses on a pin. I used it to measure RPI2040 ISR latencies and reported there. As I am not using github ...
by rkompass
Mon Jul 25, 2022 11:29 am
Forum: MicroPython pyboard
Topic: How to make PWM rising edge trigger an interrupt?
Replies: 27
Views: 69053

Re: How to make PWM rising edge trigger an interrupt?

I have to correct my previous findings. My numbers and those by @TheSilverBullet are to a great extent artefacts. The functions used for stopping the PWM signal suppressed the PWM pulse by forcing it low for a brief time (~2-3 us) but then gave way to the original PWM pulse which was much longer (25...
by rkompass
Wed Jul 20, 2022 6:47 pm
Forum: MicroPython pyboard
Topic: How to make PWM rising edge trigger an interrupt?
Replies: 27
Views: 69053

Re: How to make PWM rising edge trigger an interrupt?

Hello @TheSilverBullet, thank you for sharing code. Glad to find other inquiring minds I was trying to reproduce and improve :-) I constructed a PulseTimer class that has 2 period (=16 ns at 125 MHz) resolution. The idea is to use jmp(pin, LABEL) to get out of the loop with one instruction. The same...