spi data register

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

spi data register

2,621 次查看
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 回复

737 次查看
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 项奖励
回复