spi data register

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

spi data register

2,335件の閲覧回数
lssuer
Contributor I
I am trying to send data from one hs12 to another hs12using spi and whenever i write the data to the SPI0DR it doesnt work. It looks like the data never gets written to the register.

Here is my routine firs the setup then the send



void init_spi(void){
DDRS = 0xE2;
SPI0CR1 = 0x50;
SPI0CR2 = 0x00;
SPI0BR = 0x00;
}

void data_transfer(void)
{
// Declare Variables
for (i=0;i5;i++){



PTH &= 0x7F;
SPI0DR = data_array[i];
while (!(SPI0SR & 0x80));
PTH |= 0x80;
}
}

can anybody see or know any reason why this wouldnt send the data or copy the data into the SPI0DR register to be sent.

thanks
ラベル(1)
0 件の賞賛
返信
1 返信

451件の閲覧回数
imajeff
Contributor III
Some pointers:

1. The code you posted won't compile, so I know you have not tested it in a simple form.

2. Your selected baud rate is rather fast. Try a fairly slow rate just to make sure that's not the problem.
0 件の賞賛
返信