Hello, I am trying to check if addresses bus and data bus are well configured in my external RAM memory. I have done this algorithm
#include <XC164.h> #define low_adress 0x400000; #define high_adress 0x410000; #define high_data 0xFF; #define low_data 0x00; void main (void) { static double idata j,i,k; int xhuge *DIR; DIR = 0x400000; /* DATA BUS TEST */ for (j = low_adress; j <= high_adress; j++) { *DIR = 0x55; // I write 0101 0101 if (*DIR != 0x55) P3^3 = 1; // If what I have read is diferent to what I have written, I switch on an alarm *DIR = 0xAA; // I write 1010 1010 if (*DIR != 0xAA) P3^3 = 1; // If what I have read is diferent to what I have written, I switch on an alarm DIR++; } /* ADRESSES BUS TEST */ DIR = 0x400000; for (i = low_adress; i < high_adress; i = i + 0xFF;) { for (k = low_data; k < high_data ; k++) { *DIR = k; DIR++; } }
but the compiler throws errors. My RAM memory is mapped from 0x400000 to 0x410000 (64kB). Why does the compiler throw this errors?
Build target 'Target 1' assembling START_V2.A66... compiling PruebaRA.c... PRUEBARA.C(17): error C25: syntax error near '=' PRUEBARA.C(17): error C25: syntax error near ';' PRUEBARA.C(17): error C25: syntax error near ')' PRUEBARA.C(20): error C25: syntax error near 'if' PRUEBARA.C(20): error C25: syntax error near 'P3' PRUEBARA.C(20): error C25: syntax error near '=' PRUEBARA.C(22): error C25: syntax error near 'if' PRUEBARA.C(22): error C25: syntax error near 'P3' PRUEBARA.C(22): error C25: syntax error near '=' PRUEBARA.C(24): error C25: syntax error near '}' PRUEBARA.C(29): error C25: syntax error near 'for' PRUEBARA.C(29): error C7: compilation aborted Target not created
John, have a look at this article: www.embedded.com/.../0007feat1.htm
Thanks for your reply, This is one of two codes published in Tamir's page:
typedef unsigned char U8; /* Set the data bus width to 8 bits. */ U8 memTestDataBus(volatile U8 * address); { U8 pattern; for (pattern = 1; pattern != 0; pattern <<= 1) { //Write the test pattern. *address = pattern; //Read it back (immediately is okay for this test). if (*address != pattern) { return (pattern); } } return (0); } /* memTestDataBus() */
In this code I have some questions:
1-.How can I know if *adress pointer is located in off - chip ram and not in on - chip ram?
2-.How can I know at what adress exactly goes this pointer?
Thanks
John,
surely that information is available to you are you know your hardware.
I'm not sure I understand, but why would you care where in memory the pointer if stored? Is it not that you only care about where it points to?
There is one little issue to think about.
The test is destructive, so if the address pointer is stored in the tested memory region, bad things will happen. Same thing if the test is performed over the stack.
View all questions in Keil forum