Search found 10 matches

by rafl
Wed May 05, 2021 10:32 pm
Forum: Raspberry Pi microcontroller boards
Topic: Struggling with PIO
Replies: 2
Views: 2398

Re: Struggling with PIO

Your issue here is how you're using sideset. The sideset outputs will be set when the wait instruction begins executing, not after the wait finishes and the next instruction is about to start executing. I hope the following example program illustrates what's causing the inversion in your original co...
by rafl
Sun May 02, 2021 9:34 pm
Forum: Raspberry Pi microcontroller boards
Topic: Pico: IMU absolute Euler angle and the PD controller
Replies: 8
Views: 4947

Re: Pico: IMU absolute Euler angle and the PD controller

Nice job getting it all working, and thank you for sharing your solution! I learned a few things from it. Another approach might be to represent your states as quaternions rather than euler angles. In that representation the math gets a bit easier and you won't need the same special-cases. It looks ...
by rafl
Fri Apr 30, 2021 6:48 pm
Forum: Raspberry Pi microcontroller boards
Topic: Pico/micropython Switch callbacks
Replies: 5
Views: 4527

Re: Pico/micropython Switch callbacks

pythoncoder wrote:
Fri Apr 30, 2021 10:19 am
Putting delays in an interrupt service routine is a bad idea
Aren't these callbacks just scheduled for execution outside of the ISR context with mp_sched_schedule anyway?
by rafl
Sun Mar 28, 2021 2:13 pm
Forum: Raspberry Pi microcontroller boards
Topic: Raspberry Pi Pico timer priority
Replies: 2
Views: 5902

Re: Raspberry Pi Pico timer priority

It's my understanding that timers in the rp2 port are implemented using alarm pools described at https://raspberrypi.github.io/pico-sdk-doxygen/group__alarm.html#details. The C-level callback for those alarms does get executed from the timer interrupt handler, but the C callback that micropython pro...
by rafl
Thu Mar 25, 2021 9:02 pm
Forum: General Discussion and Questions
Topic: if statement short circuiting
Replies: 9
Views: 3989

Re: if statement short circuiting

You can use expressions with observable side-effects to find out what the implementation is doing: if False && foo[0]: pass will succeed, while if True && foo[0]: pass will tell you that foo isn't defined. Out of curiosity, which languages have a different evaluation-order for their boolean operators?
by rafl
Wed Mar 24, 2021 6:40 pm
Forum: Raspberry Pi microcontroller boards
Topic: PIO confusion
Replies: 2
Views: 2586

Re: PIO confusion

Set mappings are much more limited than out mappings. You can only address 5 pins, but also writing to those pins has to be done from immediate values, i.e. encoded directly into the instruction. That makes working with set pins a lot trickier if the desired output depends on run-time data, such as ...
by rafl
Tue Mar 23, 2021 7:56 pm
Forum: General Discussion and Questions
Topic: result of integer division of a negative integer
Replies: 2
Views: 1525

Re: result of integer division of a negative integer

// is the floor division operator, and floor(-2.5) is -3. You can use int() to explicitly round towards zero if so desired.
by rafl
Tue Mar 23, 2021 10:42 am
Forum: Raspberry Pi microcontroller boards
Topic: Using PIO OUT instruction for parallel interfaces
Replies: 4
Views: 2816

Re: Using PIO OUT instruction for parallel interfaces

Thanks - I didn't realise daily builds were a thing and just built from source after seeing the fix was merged.
by rafl
Tue Mar 23, 2021 10:19 am
Forum: Raspberry Pi microcontroller boards
Topic: Using PIO OUT instruction for parallel interfaces
Replies: 4
Views: 2816

Re: Using PIO OUT instruction for parallel interfaces

Thank you for clearing up my misunderstanding, Robert. There isn't even space in the instruction to fit a 32 bit value :oops:! With that insight, and the work you and others put into https://github.com/micropython/micropython/issues/6933, I am now able drive the 10 GPIOs I need for this particular a...
by rafl
Tue Mar 23, 2021 8:32 am
Forum: Raspberry Pi microcontroller boards
Topic: Using PIO OUT instruction for parallel interfaces
Replies: 4
Views: 2816

Using PIO OUT instruction for parallel interfaces

I wrote my first few PIO programs today and had success using set and side-set mappings to have PIO programs change GPIO pins. I now want to move on to interfacing with a device that needs more pins than set or side-set mappings can provide, so I want to use an out mapping instead. I started with @r...