SparkFun Forums 

Where electronics enthusiasts find answers.

Your source for all things Atmel.
#165915
Code: Select all
#define Waitfor1(register, BIT) while(!(register & (1<<BIT)));
#define Waitfor0(register, BIT) while((register & (1<<BIT)));
void mastermode()
{
DDRB = DDRB | ob10110000; \\ this sets the sck mosi and ss as outputs
DDRB = DDRB & ob10111111; \\ this sets miso as output
SPCR |=(1<<MSTR); \\ set as master
SPCR | = (1<<SPR0)|(1<<SPR1); \\ clock divided by 128
SPCR | = (1<<SPE);
} 
char RecieveByte()
{   Waitfor1(SPSR, SPIF);
    return SPDR;
}

 Void SendByte (char byte, int slavenumber)
{   PORTB = PORTB & ob1110111;
    SPDR = byte;
    Waitfor1(SPSR, SPIF);
}
I have written these initializations
If you check the data sheet of the sensor you find that there is a MSB and LSB for both temp and pressure readings.
Using the code i have how can i retrieve these values so i can combine them into one 16 bit value. The code am asking is for the atmega16 where port b pin 5 6 7 are the spi connections and pin 4 will be the slave select which will be connected to the sensor.
You do not have the required permissions to view the files attached to this post.