1 Tell the remote computer to stop sending data . flow_control_output = 1 1 Set serial_out to a character code to send on the serial port. if serial_in > 96 and serial_in < 123 then 1 The received character code was lower case a-z . 1 Send back the character in upper case. serial_out = serial_in - 32 259 Chapter 11 else 1 For other characters, send back the same character. serial_out = serial_in endif 1 Set a variable to indicate that a byte is ready for transmitting. data_ready_to_send = 1 endif return This routine checks the data_ready_to_send variable, which indicates whether serial_out contains a byte to be sent on the serial port. If data_ready_to_send = 1 and flow_control_input = 0, the routine sends the byte and sets flow_control_output = 1 to enable receiving another byte. transmit_serial_data: if data_ready_to_send = 1 then 1 A byte is ready to send on the serial port. if flow_control_input = 0 then 1 The flow control input is asserted. 1 Reset the variable that indicates a byte is ready to send 1 and send the byte. data_ready_to_send = 0 hserout serial_out 1 Tell the remote computer itвЂ™s OK to send more data . flow_control_output = 0 endif endif return 260 Ports for Embedded Systems C18 #define flow_control_input PORTBbits.RB4 #define flow_control_output PORTBbits.RB5 // Configure the flow-control pins as one input and one output. TRISBbits.TRISB4 = 1; TRISBbits.TRISB5 = 0; byte data_ready_to_send = 0; // Assert the flow-control output to enable receiving data on the serial port. flow_control_output = 0 This task loop calls two routines in an endless loop: while 1 receive_serial_data ; transmit_serial_data ; This function looks for a new received byte on the serial port. If a byte has arrived, the routine reads it. void receive_serial_data void if PIR1bits.RCIF == 1 // A byte has been received. Read it. serial_in = getcUSART ; // Tell the remote computer to stop sending data . flow_control_output = 1; // Set serial_out to a cha prom-electric.ru
Как исправить ошибку частотника?