Search found 2759 matches

by Roberthh
Sun Feb 14, 2016 1:21 pm
Forum: General Discussion and Questions
Topic: Supplying Arguments to viper function
Replies: 18
Views: 7739

Re: Supplying Arguments to viper function

Hi Damien, thanks for the explanation. The print statements were only in for debugging. The ptr8 cast adds 1,3 µs, which is acceptable, especially when there is a lot of data to be written. In contrast, the addressof() call takes about 4µs, but I may supply both bytes and bytearray objects, which sa...
by Roberthh
Sun Feb 14, 2016 11:37 am
Forum: General Discussion and Questions
Topic: Supplying Arguments to viper function
Replies: 18
Views: 7739

Re: Supplying Arguments to viper function

I found it. It's no bug, just a feature: changing the code makes is much slower. The first variant had about 500 ns between the first and second write, and 450 ns for the following ones. The second variant had like 14 µs between the first and second pulse, and 540 ns within the loop. addressof() see...
by Roberthh
Sun Feb 14, 2016 10:30 am
Forum: General Discussion and Questions
Topic: Supplying Arguments to viper function
Replies: 18
Views: 7739

Re: Supplying Arguments to viper function

Hello Pythoncoder, thanks for the hints. I tried to integrate that fpr my code, but something is strange. I have a piece of code that works: import pyb, stm from uctypes import addressof @micropython.viper def tft_cmd_data(self, cmd: int, data: ptr8, size: int): gpioa = ptr8(stm.GPIOA + stm.GPIO_ODR...
by Roberthh
Sun Feb 14, 2016 7:55 am
Forum: General Discussion and Questions
Topic: Supplying Arguments to viper function
Replies: 18
Views: 7739

Re: Supplying Arguments to viper function

Hello Damien, thanks for the feedback. I was not sure, and I could not find it written somewhere. I tried it and it seems to work. About your question: For practical purposes it does not matter whether it's possible to specify a pointer as R/O or R/W. The latter works in all circumstances, and you c...
by Roberthh
Sat Feb 13, 2016 8:59 pm
Forum: General Discussion and Questions
Topic: Supplying Arguments to viper function
Replies: 18
Views: 7739

Supplying Arguments to viper function

Hello all, is there a method for supplying a bytes data object to a viper function, such that it is seen as a pointer type object. I see how I can declare an int arg, and viper also does not refuse something like arg: ptr8, but call it results in an error: "can't convert bytes to int" @micropython.v...
by Roberthh
Thu Feb 11, 2016 8:15 pm
Forum: General Discussion and Questions
Topic: Optimising Python speed tutorial
Replies: 7
Views: 4531

Re: Optimising Python speed tutorial

Hello @pythoncoder, that is really a good text, and it is a big support for everyone trying to code "at the bus". And I am definitely the wrong person for see typos. Maybe Damien or someone else from the core team could have a look at it, if something would have to be amended, especially about langu...
by Roberthh
Tue Feb 09, 2016 10:49 am
Forum: General Discussion and Questions
Topic: Pin Toggle Frequency Contest against C. Please Help! :)
Replies: 41
Views: 22684

Re: Pin Toggle Frequency Contest against C. Please Help! :)

@chuckbook: Thanks. That's what I understood from your previous post about the strh instructions. What I was wondering about is, that he unconditional branch takes 2 cycles, opposed to the conditional which seems to take 4 cycles. That looks like accessing the flags adds another timing penatly. It d...
by Roberthh
Mon Feb 08, 2016 4:03 pm
Forum: General Discussion and Questions
Topic: Pin Toggle Frequency Contest against C. Please Help! :)
Replies: 41
Views: 22684

Re: Pin Toggle Frequency Contest against C. Please Help! :)

I have a piece of code that works, submitted to the other forum under a different nickname. import pyb, stm @micropython.viper def toggleViper(cnt: int): bsrr = ptr16(stm.GPIOA + stm.GPIO_BSRRL) while cnt: bsrr[0] = 1 bsrr[1] = 1 cnt -= 1 @micropython.asm_thumb def toggleASM(r0): # r0 has loop count...
by Roberthh
Thu Feb 04, 2016 12:26 pm
Forum: General Discussion and Questions
Topic: Pin Toggle Frequency Contest against C. Please Help! :)
Replies: 41
Views: 22684

Re: Pin Toggle Frequency Contest against C. Please Help! :)

Thanks. I'm very exited about this discussion, because it gives very helpful information for two applications of PyBoard, where I thought it would be too slow. But the viper mode and direct addressing of peripheral registers is just the right combination of speed and code readability.
by Roberthh
Thu Feb 04, 2016 7:26 am
Forum: General Discussion and Questions
Topic: Pin Toggle Frequency Contest against C. Please Help! :)
Replies: 41
Views: 22684

Re: Pin Toggle Frequency Contest against C. Please Help! :)

With a slightly changed loopPerformance3d() the results are a little bit better, using Port A0. I get Counted: 3,565,062 (viper4) (time=561ms) which would be 7.130.124 toggles. For comparison, I made a single endless loop toggling X1 (Port A0). The loop period is 82 ns or 12 MHz, the shortest time b...