We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I want to run a short function from internal xdata!
I use the DS80C390, I use the configuration with my internal xdata on 00F000h–00FFFFh and no external xdata. I have 128k code space.
IDM = b00 P4CNT = b100
I have a byte array which I use to allocate space in the xdata range:
xdata tyu8 aru8Code[SIZE];
Here I copy my function to xdata:
tyu8 code* u8CodePtr; tyu8 u8Index = 0; for ( u8CodePtr = ((tyu8 code*) MyFunc); u8CodePtr < ((tyu8 code*) MyFunc+SIZE); u8CodePtr++, u8Index++ ) { aru8Code[u8Index] = *u8CodePtr; }
Here I want to call my function in xdata:
((void(*)(void)) aru8Code)();
Somehow it doesn't work, the processor restarts all the time. What am I missing?
CODE and XDATA are two completely separate memory spaces. Code can not be run from XDATA, unless the processor supports a remapping so a region of XDATA will be also accessible as CODE.
Do you have any such remapping? Because just casting between XDATA and CODE pointers doesn't work.