This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Serial Communication

Question 1:

I am needing to perform I2C or SPI communication among 8031s, but I cant use open-collector pins or serial pins. I have 03 free pins on port 1. Is it possible without additional hardware ?

Question 2:

I am neending to connect a 80C31 to GPS antenna that uses 9600,8,odd,1 standard. So I am needing to program the microcontroller on mode 3 how showed bellow

void serial_config(void)
{
ES = OFF; // Disable Serial Interrupt
TR1 = OFF; // Turn OFF the timer 1
TMOD = (TMOD & 0x20) | 0x20; // Timer 1 - Mode 2 - Automatic
TL1 = 0xFA; // 9600 bps
TH1 = 0xFA; //
TR1 = ON; // Turn ON the Timer 1
PCON = 0x80; // SMOD = 1 --> double the rate
SCON = 0xD0;
// SM0 = 1 SM1 = 1 --> mode 3 of communication
// REN = 1 --> Enable Reception

RI = OFF; // Enable RI
ES = ON; // Enable Serial Interrupt
}


void int_serial(void) interrupt 4
{
if (TI) {
RS_tx_int = ON; // free to new transmition
TI = OFF; // Reset the Flag
}
if (RI) { // If exists data on reception
put_data_rx_buffer(SBUF); // read the data and put it on reception buffer
RI = OFF; // Enable reception to new data
}
}


void serial_out(byte aux)
{
while (RS_tx_int == OFF); // wait to transmit the data
TB8 = calculate_parity(aux, ODD_PARITY); // calculates the odd parity based on "Aux"
SBUF = aux; // transmit next data
RS_tx_int = OFF;
}



So, on mode 3, when I connect the MCU on PC runs ok but when I connect on GPS antenna do not run. Are there other configuration to do on setup of serial communication ? (like priority IP register ?)

Please let me see if my code is correct.

Best Regards

0