[Cryptech Tech] never do in software what can be done in hardware

Fredrik Thulin fredrik at thulin.net
Wed Sep 24 06:44:55 UTC 2014


On Thursday, September 11, 2014 06:34:06 AM Benedikt Stockebrand wrote:
...
> > It turns out that the counters the MSP430 I've been using are not "double
> > buffered" (msp430f2132, Timer A), meaning that the counter values can
> > actually be updated at the same time as I'm reading them. Decidedly not
> > good.
>
> Can you just read the least significant byte, or are they not even
> double buffered at the byte level?

AFAICT, the msp430 reads 16 bits at a time from memory. If I read a single 
byte, it appears to read a word and discard half of it.
 
> >> That's still rather slow---I have less than 50 clock cycles on average
> >> per noise bit read.
> 
> Correction: I"ve just checked the numbers, it's about 30--40 clock
> cycles depending on the frequency spectrum of the analog section.
> 
> > Yes, I optimized it and cleaned out some cruft so that I could actually
> > enable inlining without overflowing the code segment and got it down to
> > an average of 29 clock cycles (at 16 MHz), with 95% being 60 cycles or
> > less.
> 
> That sounds pretty good; looks like we're getting close to what's
> actually possible on the MCU side.

Probably, for the ~20 MHz range. I'm slowly working on a new prototype with an 
84 MHz  STM32 CPU instead. Currently using the STM32F401 Nucleo evaluation 
board. I'm quite curious to see what can be done with one of those, but I 
don't have that much time available at the moment. Will keep you posted.

...
> > I got myself an AVR ISP
> 
> Ouch, I thought you already had one; otherwise I would've pointed out
> that you can use an Arduino as a programmer as well.  At least I hope
> you didn't by any of the extra expensive stuff...

No worries. I was ordering stuff anyways and got the inexpensive Sparkfun 
Pocket AVR Programmer (https://www.sparkfun.com/products/9825).
 
> > in order to be able to get timer deltas directly from
> > an otherwise unmodified ARRGH board. Attached as ARRGH_10M_entrys.png.
> > The curve is rather smooth, and I guess the evenly spaced values (3 apart)
> > are an effect of the polling loop.
> 
> Right; I run the timer at clock speed and every sampling iteration takes
> three clock cycles.  Since I only use the least significant bit anyway
> this works out just fine.

You're in luck the sampling takes an odd number of cycles ;)

/Fredrik



More information about the Tech mailing list