Masking problem?

Hi there,

What does the following line do?

#define DD_MOSI PINB5

I understand what a define means but I am trying to figure out if PINB5 is

this:

0b00100000

or this:

0b11011111

The code where the DD_MOSI is used is below

void SPI_MasterInit(void)
{
/* Set MOSI and SCK output, all others input */
DDR_SPI = (1<<DD_MOSI)|(1<<DD_SCK);
/* Enable SPI, Master, set clock rate fck/16 */
SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR0);
}

Check the device include file, it’ll be in there.

Leon

DD_MOSI is 5. (1<<DD_MOSI) is 00100000. By or’ing it in, you are setting it to a 1 in the data direction register, so the direction of MOSI is output.