Awww c`mon, my spelling`s not That bad!
I`v been experimenting with the Digilent Uno32 board over the last 2 days, in particular to sse just How arduino compatible it is in the IDE, and what neat things can be done with a board that`s ~5X faster than a 328p chip.
being a simple soul that`s happy with an 8 bit data bus and few control lines to do almost anything I`m likely to want, the First thing I wanted to check was things DDRD and PORTD type commands.
now I know you can use pinmode and digitalwrite and stuff, but I find it more natural to write to ports directly (personal taste), the thing that really surprised me with the MPide, was that PORT`x` commands were actually allowed!
it totally didn`t like DDR`x` though, so I tried the TRIS command that PICs use and That worked just fine, a Note: on AVR chip all 1`s are Output, on PIC 0`s are output!
ie/
DDRD = B11111111 for outputs on AVR
TRISD = B00000000 for outputs on a PIC
anyway, I tried all the Arduino ports like B and D, and they`re not 100% compatible at all, in fact one of them only gives you 7 bits? so Im guessing it`s used internally or on the board for something else.
so naturaly I went through the Alphabet poking around with an LED to see what changed, and port `E` seems to be the droids I was looking for!
the magic command is TRISE.
so... I wired up my recently built D to A convertor to pins 26 to 33 (LSB to MSB respectively), and wrote probably the smallest program ever;
void setup (void) {
TRISE =B00000000;
}
void loop() {
PORTE = (analogRead(A0)>>1);
}
this little prog simply takes a reading from analog pin 0 and shoves it out as an 8 bit binary number onto pins 26-33, where the D to A board turns it back into Analog again.
you Could use /2 to make it into an 8 bit number instead, but shifting to the right ">>1" does the same only faster and uses less mem.
also the prog will take a delay of up to 50 micro seconds, so there`s plenty of room to manipulate this data if you plan on using it for Audio without any noticable effects.
use this for a simple white noise gen:
void setup()
{ TRISE = B00000000; //sets pins 26 to 33 as outputs
}
void loop()
{
int n = random(0,256); //picks a random 8 bit number
{
PORTE = n; //outputs number `n` to port E
delay(10); // kill this line for a higher frquency
}
}
or for real speed, just have this as your Loop:
PORTE =random(0,256);
Hopefully this may save someone a bit of time figuring it out for themselves, and leave them free for doing all sorts of funky Maths stuff with the data!
Now I`m off to listen to Blondie again through my Uno32 board, I have no idea why, but She`s always the "victim" of my A to D to A experiments?
C`mon baby, hit those High notes, I need to test my lowpass filter!