May. 3rd, 2014

faster!

May. 3rd, 2014 02:47 pm
sweh: (Vroomba)
Based on a hint elsewhere, I tried to see if I could get faster output...

So without getting into assembler, I looked at direct port manipulation:
  DDRD=B11111111;
  boolean x=false;
  while(1)
  {
     x=!x;
     if (x) { PORTD=255; } else { PORTD=0;}
  }

(Yeah, I'm just setting all the pins for now).

That gives me a 748Khz signal. Amazingly quicker!

Removing the boolean test
  while (1)
  {
    PORTD=255;
    PORTD=0;
  }


This is the resulting assembler:
        ldi r24,lo8(-1)
  .L4:
        out 43-32,r24
        out 43-32,__zero_reg__
        rjmp .L4

Gives me a 3.9Mhz signal!

What's interesting, here, isn't the asymmetric on/off cycle (expected; need some NOPs in there to balance it out) but that the output is really noisy with massive overshoot on both low->high and high->low
transitions!
Scope trace at 3.9Mhz )

Of course we see these spikes at lower frequencies as well, but at this high speed the stabilisation time is a large portion of the signal.
Scope trace at 748Khz )

FWIW, with two asm("nop") instructions in between the two PORTD settings I get 2.6Mhz
Scope trace at 2.6Mhz )

 0000 8FEF                  ldi r24,lo8(-1)
                    .L4:
 0002 8BB9                  out 43-32,r24
 0004 0000                  nop
 0006 0000                  nop
 0008 1BB8                  out 43-32,__zero_reg__
 000a 00C0                  rjmp .L4


Interesting stuff!
sweh: (Straight Jacket)
So I just rewatched "Hudson Hawk". This has an actress in it called "Sandra Bernhard". Which brought to mind a saying of my mother's; "Who do you think you are; Sarah Bernhardt?" (No relation; just a similarity in names).

Now Sarah Bernhardt was a French actress from the 1890s through to the early 1920s. It's likely that my mum's mum (my grandmother) had seen her in the cinema. It's not likely that she was relevant in my mother's lifetime (born 1942).

So here we have a phrase that I know well that's been handed down via 2 generations.

If we only went by word out mouth then I'd really have no idea who or what she was. Sure, from context "actress" would be a reasonable guess. But it'd be a guess; I'd have no real data.

It's no wonder that pre-writing mankind's history is blurred; "oral history" is extremely unreliable!

If the internet has one saving grace, it's that looking up this information is simple, free and takes seconds. A quick "google", a read of the wikipedia page, a couple of other references... and you know more than many other people who haven't spent those few minutes. Prior to the internet you need to buy a book (or get it from the library). Which may have given you more depth of knowledge... but was also a barrier to entry. I'd never have got a book on Bernhardt on a whim; but wikipedia? No probs!

August 2025

S M T W T F S
     12
3456789
101112 13141516
17181920212223
24252627282930
31      

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 3rd, 2025 02:45 pm
Powered by Dreamwidth Studios