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.
When i compile this code it give error like:-]
error 88: illegal cast of Literal value to 'generic' pointer from type 'literal-unsigned-char' to type 'unsigned-char generic*'
error 47:indirection to different types assignment from type 'literal-unsigned generic*' to type 'unsigned-char'
#include <8051.H> #include "Kernel.h"
#include "AVX.H" #ifndef IntSP #define xdata unsigned char * xdata IntSP; IntSP = (0xC0); #endif //--------------------------------------------------------------------------- Kernel data g_Kernel; //---------------------------------------------------------------------------
extern void Kernel_RestoreContext(); extern void Save_Stack(unsigned char idata *InternalSP, unsigned char xdata *ExternalSP ); extern void Restore_Stack(unsigned char idata *InternalSP, unsigned char xdata *ExternalSP ); extern void Init_Ram(); //--------------------------------------------------------------------------- void Kernel_ContextSwitch() { unsigned short data pc;
// Save return address. // Pop high byte of return address. *(unsigned char xdata *)&pc = *(unsigned char idata *)SP--;
// Pop low byte of return address. *((unsigned char xdata *)&pc + 1) = *(unsigned char idata *)SP--;
Save_Stack(g_Kernel.Tasks[g_Kernel.RunningTaskIndex].InternalSP , g_Kernel.Tasks[g_Kernel.RunningTaskIndex].ExternalSP ); // Save current Task's internal stack pointer. g_Kernel.Tasks[g_Kernel.RunningTaskIndex].InternalSP = ( unsigned char idata *)SP; // Save current Task's external stack pointer. // g_Kernel.Tasks[g_Kernel.RunningTaskIndex].ExternalSP = Kernel_GetXBP();
// Switch to next Task. // Round-Robin scheduling.
#ifdef PREEMPTIVE
r=LogTable256[taskRdyMatrixIndex]; c=LogTable256[taskRdyMatrix[r]];
priority = (r<<3) | c; // priority = 63 - priority; g_Kernel.RunningTaskIndex =taskRdyQue[priority];
#else
g_Kernel.RunningTaskIndex = (g_Kernel.RunningTaskIndex + 1) % g_Kernel.TaskCount; #endif
Restore_Stack(g_Kernel.Tasks[g_Kernel.RunningTaskIndex].InternalSP , g_Kernel.Tasks[g_Kernel.RunningTaskIndex].ExternalSP ); // Restore next Task's internal stack pointer. SP= (volatile unsigned char)g_Kernel.Tasks[g_Kernel.RunningTaskIndex].InternalSP; // Restore next Task's external stack pointer.
// Restore return address. // Push low byte of return address. *(unsigned char idata *)++SP = *((unsigned char xdata *)&pc + 1); // Push high byte of return address. *(unsigned char idata *)++SP = *(unsigned char xdata *)&pc;
// Note: ISR will restore next Task's all registers. } //--------------------------------------------------------------------------- void Kernel_Initialize() { #if 0 == OS_TASK_COUNT #error OS_TASK_COUNT can not be 0! #endif
// Initialize the kernel object. Init_Ram(); Initialise_Shell(); TaskCreate(Task_Idle,63, 0x6000); g_Kernel.RunningTaskIndex = 0; g_Kernel.TaskCount = 1; } //--------------------------------------------------------------------------- void Kernel_Start() {
r=LogTable256[taskRdyMatrixIndex]; // calculate highest priority task c=LogTable256[taskRdyMatrix[r]];
priority = (r<<3) | c;
g_Kernel.RunningTaskIndex =taskRdyQue[priority];
#else // roundrobin
g_Kernel.RunningTaskIndex = 0;
#endif
*(IntSP) =(unsigned char*)(g_Kernel.Tasks[g_Kernel.RunningTaskIndex].ExternalSP);
(unsigned char*) *(IntSP + 1) =((g_Kernel.Tasks[g_Kernel.RunningTaskIndex].ExternalSP)+1);
// Restore next Task's internal stack pointer. SP =(volatile unsigned char ) g_Kernel.Tasks[g_Kernel.RunningTaskIndex].InternalSP; // Restore next Task's external stack pointer. start_timer(); // start the timer // Restore first Task's all registers. Kernel_RestoreContext(); } void start_timer() { // Setup timer. TMOD |= 1; // Interrupt per millisecond. TH0 = (65536 - 20000) / 256; TL0 = (65536 - 20000) % 256; ET0 = 1; TR0 = 1; // Enable all interrupts. EA = 1;
} //--------------------------------------------------------------------------- void Initialise_Shell(void) { TMOD|=0x20; // timer 1 mode 2 auto reload TH1|=0xFD; TL1|=0xFD; // baud 9600 SCON|=0x50; // 8 bit 1 top bin 1 ren enabled IE|=0x90; // enable serial interrupt TR1|=1; }
void Task_Idle() { while(1); }
---)))))))))------((((((((==========((((((++++++++++)))))))))))))))))___________
Kernel.h file
//--------------------------------------------------------------------------- #ifndef KernelH #define KernelH //--------------------------------------------------------------------------- #include <AVX.h> #include "Task.h"
//---------------------------------------------------------------------------
void Task_Idle(); typedef struct _Kernel { unsigned char RunningTaskIndex; // Running Task index. unsigned char TaskCount; // Task count. Task Tasks[OS_TASK_COUNT]; // Task objects. } Kernel;
// Initialize the kernel. // Parameters: // None. // Return value: // None. void Kernel_Initialize(); // Context switch the kernel. // Parameters: // None. // Return value: // None. void Kernel_ContextSwitch(); // Start the kernel. // Parameters: // None. // Return value: // None. void Kernel_Start(); void start_timer(); void Task_Idle();
//--------------------------------------------------------------------------- extern Kernel data g_Kernel; //--------------------------------------------------------------------------- #endif // KernelH //---------------------------------------------------------------------------
HELP !
please re-post using the pre and /pre tags, and do add some clarifications...
Please read the instructions on how to post source code: www.danlhenry.com/.../keil_code.png
Please re-post your code, correctly formatted, in just one of your threads, and post a link in the other to the corrected version.
Be sure to check the formatting using the 'Preview' before you post!
Also, try looking-up those error messages in the Manual:
http://www.keil.com/support/man/docs/c51/c51_errors.htm