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

yet another serial question

why does my get stuck at
jnb TI, $

List:
; enable external clock 11.0592Mhz for
; standard baud rate generation
; external pin T2 stimulated from
; function generator.

		mov SCON, #01010000B
		mov  T2CON, #00110010B
		mov  TL2, #0EEh
		mov  TH2, #0FFh
		setb TR2
		clr  TI
		mov  SBUF, #'A'
		jnb  TI, $
Looking at SBUF, 'A' never seems to get moved there. What am I doing wrong?

Parents
  • Well I changed my code to use the internal clock @ 16MHz. I put a scope on P0.0 and saw the character was being transmitted repetitivley, but TI is never set. Why is this?

    $INCLUDE(C8051F200.INC)	; Register definition file.
    
          org 00h
          LJMP Config
    ; Place jump to reset handler and interrupt service routines here.
    
          org 0B3h      ; End of Interrupt Vector space.
    Config:
    
    	mov WDTCN, #007h	; Watchdog Timer Control Register
        mov WDTCN, #0DEh    ; Disable WDT
        mov WDTCN, #0ADh
    
    ; Configure the PRTnMX Registers
    
    	mov PRT0MX, #001h ; PRT0MX:	Initial Reset Value
    	mov PRT1MX, #000h ; PRT1MX: Initial Reset Value
    	mov PRT2MX, #080h ; PRT2MX: Initial Reset Value
    
    ; Select Pin I/0
    
    ; NOTE: Some peripheral I/O pins can function as either inputs or
    ; outputs, depending on the configuration of the peripheral. By default,
    ; the configuration utility will configure outputs as push-pull.
    
    ; Port configuration (1 = Push Pull Output)
    
    	mov PRT0CF, #001h ; Output configuration for P0
    	mov PRT1CF, #000h ; Output configuration for P1
    	mov PRT2CF, #000h ; Output configuration for P2
    	mov PRT3CF, #000h ; Output configuration for P3
    
    
    
    	mov P0MODE, #0FFh ; Input Configuration for P0
    	mov P1MODE, #0FFh ; Input Configuration for P1
    	mov P2MODE, #0FFh ; Input Configuration for P2
    	mov P3MODE, #0FFh ; Input Configuration for P3
    
    	mov CPT0CN, #000h	; Comparator 0 Control Register
    
    	mov CPT1CN, #000h	; Comparator 1 Control Register
    
    	;Comp1 marker
    
    ;----------------------------------------------------------------
    ; Oscillator Configuration
    ;----------------------------------------------------------------
    
    	mov OSCXCN, #010h	; External Oscillator Control Register
    
    	mov OSCICN, #007h	; Internal Oscillator Control Register
    
    
    ;----------------------------------------------------------------
    ; Reference Control Register Configuration
    ;----------------------------------------------------------------
    
    	mov REF0CN, #003h	; Reference Control Register
    
    ;----------------------------------------------------------------
    ; SPI Configuration
    ;----------------------------------------------------------------
    
    	mov SPI0CN, #000h	; SPI Control Register
    	mov SPI0CFG, #000h	; SPI Configuration Register
    	mov SPI0CKR, #000h	; SPI Clock Rate Register
    
    ;----------------------------------------------------------------
    ; UART Configuration
    ;----------------------------------------------------------------
    
    	mov SCON, #050h		; Serial Port Control Register
    
    
    
    
    
    
    
    
    	mov PCON, #000h		; Power Control Register
    
    ;----------------------------------------------------------------
    ; ADC Configuration
    ;----------------------------------------------------------------
    
    	mov AMX0SL, #000h	; AMUX Channel Select Register
    	mov ADC0CF, #000h	; ADC Configuration Register
    	mov ADC0CN, #000h	; ADC Control Register
    
    	mov ADC0LTH, #000h	; ADC Less-Than High Byte Register
    	mov ADC0GTH, #0FFh	; ADC Greater-Than High Byte Register
    
    ;----------------------------------------------------------------
    ; Timer Configuration
    ;----------------------------------------------------------------
    
    	mov CKCON, #020h	; Clock Control Register
    	mov TH0, #000h		; Timer 0 High Byte
    	mov TL0, #000h		; Timer 0 Low Byte
    	mov TH1, #000h		; Timer 1 High Byte
    	mov TL1, #000h		; Timer 1 Low Byte
    	mov TMOD, #000h		; Timer Mode Register
    	mov TCON, #040h		; Timer Control Register
    
    	mov RCAP2H, #0FFh	; Timer 2 Capture Register High Byte
    	mov RCAP2L, #0EFh	; Timer 2 Capture Register Low Byte
    	mov TH2, #0FFh		; Timer 2 High Byte
    	mov TL2, #0EFh		; Timer 2 Low Byte
    	mov T2CON, #034h	; Timer 2 Control Register
    
    	mov RSTSRC, #000h	; Reset Source Register
    
    
    ;----------------------------------------------------------------
    ; Interrupt Configuration
    ;----------------------------------------------------------------
    
    	mov IE, #000h		;Interrupt Enable
    	mov IP, #000h		;Interrupt Priority
    	mov EIE1, #000h		;Extended Interrupt Enable 1
    	mov EIE2, #000h		;Extended Interrupt Enable 2
    	mov EIP1, #000h		;Extended Interrupt Priority 1
    	mov EIP2, #000h		;Extended Interrupt Priority 2
    
    
    
    ; other initialization code here...
    
    
    
    ;-----------------------------------------------------------------
    ; MAIN PROGRAM CODE
    ;-----------------------------------------------------------------
    
    Main:
    
    	; main code routines here...
    	setb	TR2
    	clr	TI
    	mov	SBUF, #'A'
    	jnb	TI, $
    
    END
    

Reply
  • Well I changed my code to use the internal clock @ 16MHz. I put a scope on P0.0 and saw the character was being transmitted repetitivley, but TI is never set. Why is this?

    $INCLUDE(C8051F200.INC)	; Register definition file.
    
          org 00h
          LJMP Config
    ; Place jump to reset handler and interrupt service routines here.
    
          org 0B3h      ; End of Interrupt Vector space.
    Config:
    
    	mov WDTCN, #007h	; Watchdog Timer Control Register
        mov WDTCN, #0DEh    ; Disable WDT
        mov WDTCN, #0ADh
    
    ; Configure the PRTnMX Registers
    
    	mov PRT0MX, #001h ; PRT0MX:	Initial Reset Value
    	mov PRT1MX, #000h ; PRT1MX: Initial Reset Value
    	mov PRT2MX, #080h ; PRT2MX: Initial Reset Value
    
    ; Select Pin I/0
    
    ; NOTE: Some peripheral I/O pins can function as either inputs or
    ; outputs, depending on the configuration of the peripheral. By default,
    ; the configuration utility will configure outputs as push-pull.
    
    ; Port configuration (1 = Push Pull Output)
    
    	mov PRT0CF, #001h ; Output configuration for P0
    	mov PRT1CF, #000h ; Output configuration for P1
    	mov PRT2CF, #000h ; Output configuration for P2
    	mov PRT3CF, #000h ; Output configuration for P3
    
    
    
    	mov P0MODE, #0FFh ; Input Configuration for P0
    	mov P1MODE, #0FFh ; Input Configuration for P1
    	mov P2MODE, #0FFh ; Input Configuration for P2
    	mov P3MODE, #0FFh ; Input Configuration for P3
    
    	mov CPT0CN, #000h	; Comparator 0 Control Register
    
    	mov CPT1CN, #000h	; Comparator 1 Control Register
    
    	;Comp1 marker
    
    ;----------------------------------------------------------------
    ; Oscillator Configuration
    ;----------------------------------------------------------------
    
    	mov OSCXCN, #010h	; External Oscillator Control Register
    
    	mov OSCICN, #007h	; Internal Oscillator Control Register
    
    
    ;----------------------------------------------------------------
    ; Reference Control Register Configuration
    ;----------------------------------------------------------------
    
    	mov REF0CN, #003h	; Reference Control Register
    
    ;----------------------------------------------------------------
    ; SPI Configuration
    ;----------------------------------------------------------------
    
    	mov SPI0CN, #000h	; SPI Control Register
    	mov SPI0CFG, #000h	; SPI Configuration Register
    	mov SPI0CKR, #000h	; SPI Clock Rate Register
    
    ;----------------------------------------------------------------
    ; UART Configuration
    ;----------------------------------------------------------------
    
    	mov SCON, #050h		; Serial Port Control Register
    
    
    
    
    
    
    
    
    	mov PCON, #000h		; Power Control Register
    
    ;----------------------------------------------------------------
    ; ADC Configuration
    ;----------------------------------------------------------------
    
    	mov AMX0SL, #000h	; AMUX Channel Select Register
    	mov ADC0CF, #000h	; ADC Configuration Register
    	mov ADC0CN, #000h	; ADC Control Register
    
    	mov ADC0LTH, #000h	; ADC Less-Than High Byte Register
    	mov ADC0GTH, #0FFh	; ADC Greater-Than High Byte Register
    
    ;----------------------------------------------------------------
    ; Timer Configuration
    ;----------------------------------------------------------------
    
    	mov CKCON, #020h	; Clock Control Register
    	mov TH0, #000h		; Timer 0 High Byte
    	mov TL0, #000h		; Timer 0 Low Byte
    	mov TH1, #000h		; Timer 1 High Byte
    	mov TL1, #000h		; Timer 1 Low Byte
    	mov TMOD, #000h		; Timer Mode Register
    	mov TCON, #040h		; Timer Control Register
    
    	mov RCAP2H, #0FFh	; Timer 2 Capture Register High Byte
    	mov RCAP2L, #0EFh	; Timer 2 Capture Register Low Byte
    	mov TH2, #0FFh		; Timer 2 High Byte
    	mov TL2, #0EFh		; Timer 2 Low Byte
    	mov T2CON, #034h	; Timer 2 Control Register
    
    	mov RSTSRC, #000h	; Reset Source Register
    
    
    ;----------------------------------------------------------------
    ; Interrupt Configuration
    ;----------------------------------------------------------------
    
    	mov IE, #000h		;Interrupt Enable
    	mov IP, #000h		;Interrupt Priority
    	mov EIE1, #000h		;Extended Interrupt Enable 1
    	mov EIE2, #000h		;Extended Interrupt Enable 2
    	mov EIP1, #000h		;Extended Interrupt Priority 1
    	mov EIP2, #000h		;Extended Interrupt Priority 2
    
    
    
    ; other initialization code here...
    
    
    
    ;-----------------------------------------------------------------
    ; MAIN PROGRAM CODE
    ;-----------------------------------------------------------------
    
    Main:
    
    	; main code routines here...
    	setb	TR2
    	clr	TI
    	mov	SBUF, #'A'
    	jnb	TI, $
    
    END
    

Children