EP9315 arm,sja1000 can,wince5.0 参考周立功magic arm的读写函数 void SJA1000_ReadRegister(UINT8 reg, UINT8 *value) { //g_lpBaseSJA1000[8] = reg; //*value = (UINT8)g_lpBaseSJA1000[4]; //return (*(volatile UCHAR * const)Register); WRITE_REGISTER_UCHAR((PUCHAR)&g_lpBaseSJA1000[8], reg); *value = READ_REGISTER_UCHAR((PUCHAR)&g_lpBaseSJA1000[4]); #ifdef DEBUG RETAILMSG(1,(TEXT("read from[0x%02x]=[0x%02x]
"),reg,*value)); #endif }
void SJA1000_WriteRegister(UINT8 reg, UINT8 value) { //g_lpBaseSJA1000[4] = reg; //g_lpBaseSJA1000[8] = value; #ifdef DEBUG RETAILMSG(1,(TEXT("write to[0x%02x]=[0x%02x]
"),reg,value)); #endif WRITE_REGISTER_UCHAR((PUCHAR)&g_lpBaseSJA1000[8], reg); WRITE_REGISTER_UCHAR((PUCHAR)&g_lpBaseSJA1000[4], value); }可以写进sja1000,这个通过写CDR分频系数改变CLKOUT脚的频率,通过示波器得知 读的时候读回来的都是要读数据的地址,好像读得太快了,刚把地址送出,还没等到数据,就读,结果读到地址了,因sja1000地址数据线复用。各位大侠有什么看法。 串口打印信息如下 read from[0x00]=[0x00] read from[0x01]=[0x01] read from[0x02]=[0x02] read from[0x03]=[0x03] read from[0x04]=[0x04] read from[0x05]=[0x05] read from[0x06]=[0x06] read from[0x07]=[0x07] read from[0x08]=[0x08] read from[0x09]=[0x09] |