<div style="line-height:1.7;color:#000000;font-size:14px;font-family:arial"><P>Recently , I want to write data to register of can device. At first I use IO space , so I can't make the device operated. Later, I change to use memory space. I can send data and receive data from the register.</P><SPAN style="FONT-SIZE: 18px">
<P></P><SPAN style="COLOR: #ff0000">
<P>IO space:</P></SPAN></SPAN>
<P><SPAN style="FONT-SIZE: 18px; COLOR: #ff0000"></SPAN>/*<BR>---------------------------------------------------<BR> 两个最基本的SJA1000寄存器读写函数<BR>*/<BR>/*unsigned char read_sja(unsigned char RegNum)<BR>{<BR> unsigned char bValue;</P>
<P> RegNum &= 0x7F; //最高位清0</P>
<P> inport_byte(BASE_ADDRESS+RegNum,bValue);</P>
<P> return (bValue);<BR>}</P>
<P>void write_sja(unsigned char RegNum, unsigned char bValue)<BR>{<BR> RegNum &= 0x7F; //最高位清0<BR> outport_byte(BASE_ADDRESS+RegNum,bValue);<BR> delay(50000);<BR>}*/</P><SPAN style="FONT-SIZE: 18px">
<P></P><SPAN style="COLOR: #ff0000">
<P>memory space:</P></SPAN></SPAN>
<P><SPAN style="FONT-SIZE: 18px; COLOR: #ff0000"></SPAN>unsigned char read_sja(unsigned char RegNum)<BR>{<BR> unsigned char data;<BR> RegNum &= 0x7F;<BR> data = * (volatile unsigned char *)((BASE_ADDRESS)+RegNum);<BR> return (data);<BR>}<BR>void write_sja(unsigned char RegNum, unsigned char data)<BR>{<BR> RegNum &= 0x7F;<BR> * (volatile unsigned char *)((BASE_ADDRESS)+RegNum) = data; <BR>}</P>
<P>By the way , not all the PC-104 have can module. If you PC-104 have can module, you can follow the manual. But you must find out if the operation of register is IO space or memory space.</P></div><br><br><span title="neteasefooter"><span id="netease_mail_footer"></span></span>