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, $
Yes I see T2 changing values. Now I used config.exe to configure everything. I am merely using a proto board with a Silicon Labs C8051F226 MCU. Here is the updated code. The same thing happens. I guess I'll try to install a real 11.059MHz crystal.
$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, #041h ; 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, #040h ; 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, #087h ; 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 anl SCON, #0FCh ; clear interrupt pending flags 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, #000h ; 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, #0EEh ; Timer 2 Capture Register Low Byte mov TH2, #0FFh ; Timer 2 High Byte mov TL2, #0EEh ; Timer 2 Low Byte mov T2CON, #036h ; Timer 2 Control Register ;--------------------------------------------------------------- ; Reset Source Configuration ; ; Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 ;------------------------------------------------------------------ ; | R | R/W | R/W | R | R | R/W | R ;------------------------------------------------------------------ ;Reserved|NOT | Comp.0 | S/W | WDT | Miss. | POR | HW ; |USED | Reset/ | Reset | Reset | Clock | Force | Pin ; | | Enable | Force | Flag | Detect| & | Reset ; | | Flag | & | | Flag | Flag | Flag ; | | | Flag | | | ;------------------------------------------------------------------ ; ; NOTE! : Comparator 0 must be enabled before it is enabled as a ; reset source. ;------------------------------------------------------------------ mov RSTSRC, #000h ; Reset Source Register ;---------------------------------------------------------------- ; Interrupt Configuration ;---------------------------------------------------------------- mov IE, #010h ;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
Yes I see T2 changing values what does that prove? If you are running T2IN too fast, it will still pick up sometimes. 1) Why are you trying to run the UART with an external clock? 2) what happens if you try to communicate using the CPU clock? Erik
jnb TI, $ END Once TI get set, your program goes to uncharted territory. Erik