Search found 3144 matches

by dhylands
Tue May 21, 2019 2:59 pm
Forum: ESP32 boards
Topic: external interrupts spam
Replies: 4
Views: 84

Re: external interrupts spam

The way that I would normally deal with this is that I would use a timer along with the pin. When the first pin interrupt occurs it would disable the pin interrupt and start a timer. When the timer interrupt occurs, then you reenable the pin interrupt. You don't want to put sleeps in the interrupt r...
by dhylands
Mon May 20, 2019 1:39 pm
Forum: Other Boards
Topic: [STM32F412RG] porting micropython flash memory problems
Replies: 5
Views: 85

Re: [STM32F412RG] porting micropython flash memory problems

In order to use 64k of one of the 64k flash blocks, you'll need to increase the size of flash_cache_mem from 16k to 64k.
by dhylands
Mon May 20, 2019 1:04 pm
Forum: Programs, Libraries and Tools
Topic: MemoryError on importing large files
Replies: 4
Views: 69

Re: MemoryError on importing large files

It's because the large file needs to be compiled into bytecode. When the smaller files are being compiled the compilation process takes less memory with the smaller files.

You could also try pre compiling the large python file into a .mpy file (using mpy-cross) and uploading the .mpy file.
by dhylands
Mon May 20, 2019 12:58 pm
Forum: MicroPython pyboard
Topic: Pyboard switches to DFU mode by itself
Replies: 1
Views: 39

Re: Pyboard switches to DFU mode by itself

The only reason that the pyboard should be entering DFU mode is if the BOOT0 pin (which is labeled DFU on the back of the pyboard) is being pulled high during reset. The schematic shows a pulldown on that pin, but if it had a cold solder joint or something then that could happen. You might want to t...
by dhylands
Fri May 17, 2019 12:01 am
Forum: General Discussion and Questions
Topic: Fastest way to modify a bytearray?
Replies: 6
Views: 142

Re: Fastest way to modify a bytearray?

Yep - I'm not surprised, and I really just wanted to point out that there is a performance/memory usage tradeoff to make here. Pick whichever one is more important for your application.
by dhylands
Thu May 16, 2019 10:07 pm
Forum: General Discussion and Questions
Topic: Fastest way to modify a bytearray?
Replies: 6
Views: 142

Re: Fastest way to modify a bytearray?

By calling bytearray it winds up allocating a new bytearray. What I meant is that you can do something like this: >>> def bytearray_mod(b1, b2): ... for idx, item in enumerate(b1): ... b2[idx] = item + 100 ... >>> b1 = bytearray([1, 2, 3, 4]) >>> b2 = bytearray(4) >>> bytearray_mod(b1, b2) >>> b1 by...
by dhylands
Thu May 16, 2019 6:54 pm
Forum: General Discussion and Questions
Topic: Fastest way to modify a bytearray?
Replies: 6
Views: 142

Re: Fastest way to modify a bytearray?

bytearrays are modifiable in place, so you can also just modify the elements in place. Not sure if this is faster than what you've suggested, but it uses less memory.
by dhylands
Mon May 13, 2019 4:33 am
Forum: MicroPython pyboard
Topic: frequency counter
Replies: 6
Views: 2021

Re: frequency counter

You can manipulate the timer registers directly from upy. Use the stm module. You can see an example here: https://github.com/dhylands/upy-examples/blob/master/gated.py For your use case, you want to have an external clock source (described in the STM32F4xx Reference Manual in section 18.3.3 - Clock...
by dhylands
Thu May 09, 2019 4:34 pm
Forum: General Discussion and Questions
Topic: Structured prog & global variables
Replies: 8
Views: 195

Re: Structured prog & global variables

Now we define the same function but in a module: my_module.py : def foo(): global bar bar = bar + 1 return bar >>> import my_module >>> bar = 5 >>> my_module.foo() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "my_module.py", line 3, in foo NameError: name 'bar' isn't ...
by dhylands
Tue May 07, 2019 2:09 pm
Forum: Development of MicroPython
Topic: Custom port A9G module: help wanted
Replies: 29
Views: 860

Re: Custom port A9G module: help wanted

Well I don't know how you can possibly have a working port without a call to gc_init.