STC89C52RC serial port baud rate program

First, here is the complete code:

#include

#define uchar unsigned char

#define uint unsigned int

void send(uchar state)

{

SBUF = state;

while (TI == 0);

TI = 0;

}

void SCON_init(void)

{

TMOD = 0x20; // 6T mode, 11.05992MHz @ 115200 bps

SCON = 0x50;

PCON = 0x80;

TL1 = 0xFF;

TH1 = 0xFF;

TR1 = 1;

/*

SCON = 0x50; // Timer 2 mode, 11.0592MHz @ 115200 bps

TH2 = 0xFF;

TL2 = 0xFD;

RCAP2H = 0xFF;

RCAP2L = 0xFD;

TCLK = 1;

RCLK = 1;

C_T2 = 0;

EXEN2 = 0;

TR2 = 1;

*/

}

void main()

{

SCON_init();

while (1)

{

send('A');

}

}

Second, additional notes:

The function SCON_init() is used to configure and initialize the serial port baud rate. It should be called once at the start of the program. This function includes two different configurations for setting up the serial communication.

The first configuration uses Timer 1 in 6T mode, which is suitable for standard 51 microcontrollers. The second one, commented out, uses Timer 2 in 12T mode. This version is only available on enhanced 51 microcontrollers like the STC89C52RC.

When programming, you can choose between 6T or 12T mode based on your specific needs. There's no need to set it through code; it depends on how you initialize the timer. The choice of Timer 1 or Timer 2 also depends on the microcontroller model you're using.

In the example above, the program continuously sends the character 'A' via the serial port. This is a simple demonstration of how the serial communication works with proper initialization. You can modify the send() function to transmit other characters or data as needed.

It's important to make sure that the baud rate settings match the hardware clock frequency. In this case, the code assumes an 11.0592 MHz crystal oscillator, which is commonly used for accurate baud rates like 115200 bps.

PVC button wrap

PVC button wrap refers to a type of packaging material made from polyvinyl chloride (PVC) that is used to wrap and protect buttons. This wrap is transparent and durable, allowing the buttons to be showcased while also keeping them safe from scratches, dust, and other potential damage.

PVC button wrap is commonly used in the garment and fashion industry, where buttons are often sold in bulk or individually. It provides a professional and attractive presentation for buttons, making them more appealing to customers. Additionally, the PVC material is flexible and can be easily cut or folded to accommodate different button sizes and shapes.

PVC Button Wrap Sleeve,PVC Button Tube,Silver PVC Button Tube,PVC Button Sleeves

Dongguan Liansi Electronics Co.,Ltd , https://www.liansisleeve.com