SparkFun Forums 

Where electronics enthusiasts find answers.

Your source for all things Atmel.
By pavi017
#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.
long long title how many chars? lets see 123 ok more? yes 60

We have created lots of YouTube videos just so you can achieve [...]

Another post test yes yes yes or no, maybe ni? :-/

The best flat phpBB theme around. Period. Fine craftmanship and [...]

Do you need a super MOD? Well here it is. chew on this

All you need is right here. Content tag, SEO, listing, Pizza and spaghetti [...]

Lasagna on me this time ok? I got plenty of cash

this should be fantastic. but what about links,images, bbcodes etc etc? [...]