C8051F外部存储器读写

时间:2022-02-05 19:21:57

本质是movx指令,可用_AT_,XBYTE (absacc.h)控制读写。 


//外部xram写

void xram_write(unsigned int addr, char byte)
{
   char xdata * data pwrite;           // write pointer


   pwrite = (char xdata *) addr;       // initialize write pointer
   


   *pwrite = byte;                     // write the byte


}


//外部xram读
char xram_read(unsigned int addr)
{
   char xdata * data pread;           // read pointer


   pread = (char xdata *) addr;       // initialize read pointer
   


   return *pread;                     // read the byte


}