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.
To avoid the overhead of printf() I have created the following routine:
void write_0(unsigned char* c) { int cnt = 0; int len = strlen( c ); // Disable interrupts EA = 0 ; for ( cnt = 0; cnt < len; cnt++ ) { tx_buffer_0[ tx_write_0++ ] = c[ cnt ]; } //__for ( i = 0; i < len; i++ )__ EA = 1; // Prime buffer if ( sys_tx_0_ready ) { sys_tx_0_ready = 0; TI_0 = 1; } //__if ( sys_tx_0_ready )__ }
In my serial ISR I have the following:
void Serial_isr(void) interrupt 4 { // Handle port 0 tx if ( TI_0 ) { TI_0 = 0; if ( sys_tx_0_ready == 0 ) { SBUF0 = tx_buffer_0[ tx_read_0++ ]; if ( tx_write_0 == tx_read_0 ) sys_tx_0_ready = 1; }//__if ( sys_tx_0_ready == 0 )__ } //__if ( TI_0 )__ }
The code works, I was just wondering if anyone could suggest a better way of doing this.
Thanks.