How can I access external RAM on the PIC17 devices?
Q. I want to read and write some external RAM memory on a PIC 17C series device, but the compiler doesn’t support it. A. Here are some sample routines that will do this. These read and write 16 bit words from external memory. Usage is something like: #define ARRAY_BASE 0x8000 WriteMem(ARRAY_BASE+offset, value); Here are the functions: void WriteMem(unsigned short Adr, unsigned short Val) { #asm movfp (?_WriteMem+0),tblptrl ; Load the table address lo byte movfp (?_WriteMem+1),tblptrh ; Load the table address hi byte tlwt l,?_WriteMem+2 tablwt h,,?_WriteMem+3 #endasm } unsigned short ReadMem(unsigned short Adr) { #asm GLOBAL btemp movfp (?_ReadMem+0),tblptrl ; Load the table address lo byte movfp (?_ReadMem+1),tblptrh ; Load the table address hi byte tablrd l,,btemp ; Read memory, dummy transfer tlrd l,btemp ; Transfer lo byte to RAM tlrd h,btemp+1 ; Transfer hi byte to RAM return #endasm } If you compile this and get an error about btemp not being defined, then add the following: #asm