atmega2560 - LTC2440 SPI communication...need help troubleshooting

Apr 13, 2012 1 Replies

New guy here trying to talk to an AD board via SPI. Was hoping someone might help me troubleshoot.


I have an ATmega2560 attached to a STK600 development board. I'm trying to get data off of a LTC2440cgn AD board. But all I get out is 0...


The AD board is 24 bit resolution, but produces a 32 bit value with the data being in bits 5-28... so I figure first I need to read in 4 bytes from the AD via SPI. Then I combine 4 those four bytes into one and peel off the data bits. Then I send the 8 most significant bits to LEDs to see if I'm getting anything.


Here is my function to initialize the SPI...


void InitSPI(void) { //SPI is done through PORTB. SS is pin0, SCK is pin1, MOSI is pin2 DDRB = (1


g to

om

f

if

MOSI is pin2

I need this?

=A0 =A0//data bits are 5-28

t

ta

n

to test output

w Loop is executing

Just one thing i can think of, but might not be the problem. SS is not automatic in SPI master mode. Might want to add PORTB |=3D (1

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required