Search found 20 matches

by samneggs
Fri Aug 19, 2022 10:14 pm
Forum: Raspberry Pi microcontroller boards
Topic: How to load 32 bit constant from assembler with @micropython.asm_thumb
Replies: 6
Views: 24090

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

Peter's method of passing an array does most of the heavy lifting for me but I also use data directive and even math to come up with constants. Here's an example of the array method with constants: SCRN = const(0) GPIO = const(4) X_POS = const(8) Y_POS = const(12) X_VEL = const(16) Y_VEL = const(20)...
by samneggs
Fri Jul 22, 2022 3:41 am
Forum: Raspberry Pi microcontroller boards
Topic: Locked out of my code or: How can I reasonably use the watchdog?
Replies: 7
Views: 3050

Re: Locked out of my code or: How can I reasonably use the watchdog?

You can use core-1 to count down a global variable and if it gets to zero do a processor reset.
Then on your main routine in core-0 set the variable to a preset value.
This doesn’t work if core-1 crashes but if the code is small and simple it’ll be safe.
by samneggs
Sat Mar 05, 2022 6:18 pm
Forum: General Discussion and Questions
Topic: TypeError: can't convert __enter__ to float
Replies: 5
Views: 1976

Re: TypeError: can't convert __enter__ to float

Not very practical but you could probably get it to work with _thread if you rewrite your code using integer math instead of floating point and not dynamically create objects in the main loop. I've had solid success with using _thread but the above compromises combined with the inherent complexity o...
by samneggs
Fri Feb 18, 2022 8:29 pm
Forum: General Discussion and Questions
Topic: Disappearing Memory
Replies: 2
Views: 2677

Re: Disappearing Memory

I think I figured out a workaround for my low memory problem but I'd still like to know more about how MicroPython allocates memory. My programs are typically one file that grows as I add functions until I run out of memory. For example, I type in many lines of text to Thonny and push run. Does this...
by samneggs
Sun Feb 13, 2022 11:31 pm
Forum: General Discussion and Questions
Topic: Disappearing Memory
Replies: 2
Views: 2677

Disappearing Memory

What contributes to the memory used by a program? Not lists or arrays, just logic. And not normal Python - Assembly only. This should be straight forward - one instruction per line, roughly 1200 lines. To start with a get a baseline: import gc print(gc.mem_free()) a=bytearray(180_000) print(gc.mem_f...
by samneggs
Sun Jan 23, 2022 2:19 am
Forum: General Discussion and Questions
Topic: Size Limit for Viper Emitter Code?
Replies: 0
Views: 9752

Size Limit for Viper Emitter Code?

NotImplementedError: native method too big

I get this error when adding any viper code past a certain point. In my case it's about 125 lines. I would imagine the density of the lines may come into play. I'm using a Pico and tried on version 15 and 18.

Sam
by samneggs
Thu Jan 13, 2022 2:01 am
Forum: General Discussion and Questions
Topic: Faster Array Element Assignment - Solved
Replies: 3
Views: 8368

Re: Faster Array Element Assignment - Solved

I figured out a way of loading up to 16 arguments in one line. Here is four at one time but it can be repeated four times. There is 1.6x speed improvement over repeating this four times: my_array[0] = my_value. The store_asm() function takes four parameters and returns the memory address that they a...
by samneggs
Wed Jan 12, 2022 2:27 am
Forum: General Discussion and Questions
Topic: Faster Array Element Assignment - Solved
Replies: 3
Views: 8368

Re: Faster Array Element Assignment (not Lists)

Thanks for the reply. I was hoping I overlooked some simple method of loading an array.
Sam
by samneggs
Mon Jan 10, 2022 1:58 am
Forum: General Discussion and Questions
Topic: Faster Array Element Assignment - Solved
Replies: 3
Views: 8368

Faster Array Element Assignment - Solved

Looking for the faster way to assign elements to a small array. Is there an native way to do this? arry[0:2] <-- 100,200,300 The idea is that the values 100,200,300 would be constantly changing. Here is a way for 1-3 elements that is up to 1.45x faster than the traditional way. import array a=array....
by samneggs
Mon Dec 27, 2021 9:24 pm
Forum: General Discussion and Questions
Topic: Assembly Line Function
Replies: 0
Views: 8360

Assembly Line Function

I came across this and gave it a whirl: 'THE EXTREMELY FAST LINE ALGORITHM Variation E (Addition Fixed Point PreCalc)' Here it is where 'screen' is a 240x240 bytearray. I'm using a 16 bit RGB565 display where 1 pixel is two bytes. I converted from C into MicroPython Viper. # THE EXTREMELY FAST LINE ...