Rick-100 / STC15F104-Hello-World

Some basic programs for getting started with the STC15F104 and SDCC compiler
MIT License
4 stars 1 forks source link

9600 Baud rate for UART in STC15F104W #1

Open praveen-petal opened 11 months ago

praveen-petal commented 11 months ago

Hai, I had seen your program, but i want to write the this program fr 9600 baud rate. how to do it?

Regards Praveen M

Rick-100 commented 11 months ago

You can try this. Replace the Delay2400 function with this:

void Delay9600(){ // 1 bit time for 9600 baud at 12 MHz (104 uSeconds) asm nop nop push 0x30 MOV 0x30,#246 NEXT: djnz 0x30,NEXT pop 0x30 endasm; }

Then replace all the Delay2400() calls in the program with Delay9600()

I just used the delay tool in the STC-ISP program to generate the assembly code for 104 uSeconds at 12 MHz. The format has to be changed a little for the assembler in SDCC. I compiled the code but didn't test it on the hardware. You may need to indent the code between the asm and endasm directives like the original Delay2400 routine. I typed it in the indentions but they get removed in this comment. Good luck.