|
楼主 |
发表于 2006-12-4 15:59:19
|
显示全部楼层
楼上的大侠,我的寄存器读回来的值全是0xFF
SCCBSendByte(SENSOR,0xFF,0x01);
SubAddress = 0x04;
CharValue = 0x20;
SCCBSendByte(SENSOR,SubAddress,CharValue);
CharValue = SCCBReceiveByte(SENSOR,SubAddress);
其中
uint8 SCCBReceiveByte(uint8 SCCBAddr, uint8 SubAddr)
{
uint8 value;
/* 2-phase write */
SCCBStart();
SCCBWriteChar(SCCBAddr);
SCCBWriteChar(SubAddr);
SCCBStop();
/* 2-phase read */
SCCBStart();
SCCBWriteChar(SCCBAddr | 0x01);
value = SCCBReadChar();
SCCBStop();
return value;
}
void SCCBSendByte(uint8 SCCBAddr, uint8 SubAddr, uint8 SendData)
{
SCCBStart();
SCCBWriteChar(SCCBAddr);
SCCBWriteChar(SubAddr);
SCCBWriteChar(SendData);
SCCBStop();
}
[em04] |
|