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 in C

The serial communication with my self-made 8031 board works in assembler (beneath) but it does not work properly with C code doing the same. Anyone to know what the problem may be? Thanks

NAME SAMPLE

DS 10H

CSEG AT 0A100h


START: MOV SP,#50

; Oscillator frequency = 11.059 MHz
MOV TMOD,#00100000B ;C/T = 0, Mode = 2
MOV TH1,#0FDH
SETB TR1
MOV SCON,#01010010B

MOV A, #"a"
REPEAT:
JNB TI,$
CLR TI
MOV SBUF,A
SJMP REPEAT

END

Parents
  • #pragma iv(0xA000)
    #include "reg51.h"
    #include <stdio.h>
    
    void main (void){
      TMOD = 0x20;
      TH1 = 0xFD;
      TR1 = 1;
      SCON = 0x52;
      //printf("a");
    }
    

    This is my C code.
    The board sends 06h 02h 01h 05h 0BFh 0CAh 04h 05h even without calling the printf function.
    "Hello word" works the same way. When usig simulator, everything is ok.

Reply
  • #pragma iv(0xA000)
    #include "reg51.h"
    #include <stdio.h>
    
    void main (void){
      TMOD = 0x20;
      TH1 = 0xFD;
      TR1 = 1;
      SCON = 0x52;
      //printf("a");
    }
    

    This is my C code.
    The board sends 06h 02h 01h 05h 0BFh 0CAh 04h 05h even without calling the printf function.
    "Hello word" works the same way. When usig simulator, everything is ok.

Children
No data