Hi all,
I'm trying to send 16 bits of information (4 padding zero's and 12 real data bits) to a Maxim MAX531 DAC using Codevision AVR V2.03.5 along with a Mega32 running at 1Mhz with its internal RC clock.
Basically I had a for loop which runs from 0 to 4095, a couple of macros (found whilst lurking... courtesy of Mr Rogers on the Yahoo Codevision group - thanks!) which split the 16 bit count into hi and lo bytes which I then tried to send to my DAC using the SPI.
I was able to send the lo byte and make that set the DAC nicely but for some reason I can't get the DAC to load all 16 bits.
Using the simulator I can see that the hi / lo macros are working correctly.
I expected that I'd just be able to do something like this:
SS = 0;
junk = spi(hi_byte); //Send hi byte, read last
junk = spi(lo_byte); //Send lo byte, ditto
...but this only works for the first byte.
SPSR is set to 0xD0, and SPSR to 0x00.
I would post my code, but I have that many tryout versions I'm not sure which one is best to post.
Currently version control isn't one of my strong points. Must do better :oops:
Is what I'm doing reasonable - can the spi() routine do what I'm wanting or do I need to do this by bit banging ?
Thanks
Robin
PS I have spent some time searching the archives and the web for suitable clues but didn't find the answer - I found lots of posts which said that spi was fairly trivial to use, so I feel an even bigger dumbo now. :roll: