Hello everyone. I'm doing a RTOS project, about using kick- starting technique for interrupt driven (UART). i using KeilC 4, and mu code:
#include <REGX51.H> #define MAX 50 typedef enum { FALSE = 0, TRUE = !FALSE } bool; bool coban; struct QueueRecord; typedef struct QueueRecord *Queue; void MakeEmpty( Queue Q ); int IsEmpty( Queue Q ); int IsFull( Queue Q ); CreateQueue( int MaxElements ); int Enqueue( char ItemIn, Queue Q ); int Dequeue( Queue Q ); void UART_init(); void UART_putchar(char ch); char UART_get_byte(void); void SendDataProcedure(); /***************ISR************/ void serial() interrupt 4 { if (RI == 1){ /* ngat nhan da xay ra */ RI = 0; UART_get_byte(); Enqueue( SBUF ); if(coban == FALSE ) SendDataProcedure(); } else{ if (TI == 1){ TI = 0; coban = 0; SendDataProcedure(); } } } /**************OUTPUT ROUTINE***********/ void SendDataProcedure(){ char ch; if (!IsEmpty()){ Dequeue (&ch); SBUF = ch; coban = TRUE; } else return(); } /***************QUEUE***************/ typedef struct QueueRecord { char Array[MAX]; int Capacity; int Front; int Rear; int Size; }; void MakeEmpty( Queue Q ) { Q->Size = 0; Q->Front = 0; Q->Rear = 0; } int IsEmpty( Queue Q ) { return Q->Size == 0; } int IsFull( Queue Q ) { return Q->Size == Q->Capacity; } CreateQueue( int MaxElements ) { Queue Q; Q->Capacity = MaxElements; MakeEmpty( Q ); return Q; } int Enqueue( char ItemIn, Queue Q ){ if (Q->Rear==MAX-1 ) Q->Rear=0; else (Q->Rear)++; Q->Array[ Q->Rear ] = ItemIn; } int Dequeue( Queue Q ) { // if( IsEmpty( Q ) )return 0; // else { if (Q->Front ==MAX-1) Q->Front=0; else Q->Front++; return(Q->Array[Q->Front]); } /************* UART*******************/ void UART_init() { SCON = 0x50; // Enable UART set by timer1 TMOD = 0x20; //Timer1 che do 2 tu nap lai TH1 = 0xFD; // baurate = 9600 TR1 = 1; //khoi dong timer1 IE = 0x91; // cho phep cac ngat xay ra } void UART_putchar(char ch) { SBUF = ch; while(!TI); TI = 0; } char UART_get_byte(void) { return SBUF; } /*****************MAIN***************/ void main(){ CreateQueue( 8 ); UART_init(); coban = TRUE; UART_putchar ("tu"); }
but KeilC annouce that error "Kickstart.c(30): error C100: unprintable character 0xEC skipped" for the line i BOLDed
Please help me, thank alot
So retype that source code line then, since you have managed to get a bad character (potentially not visible with the used font).