hello,
I need to implement a software USART in FX2 using Port E.I have program for UART. I wanted to include a clock to it . I have sync problem. More over Iam not able to assign port E for FX2 in KEIL . It has port 0,1,2,3 only.Iam using assembler program. Iam posting the code .Any help will be appricated
PUBLIC _putc txd_pin EQU P3.7 ;Transmit on this pin CS EQU P3.3 ;CHIP SELECT clk EQU P3.0 ;CLK //;Formula to calculate the bit time delay constant ;This constant is calculated as: (((crystal/baud)/12) - 5) / 2 ;crystal is the frequency of crystal in Hz ;baud is required baudrate ;Please try to keep baudrate below 9600 ;to get best results :-) BITTIM EQU 45; (((11059200/9600)/12) - 5) / 2 LOOkUp: DB 03H,05H _main: MOV DPTR,#0000 ;load address from lable CLR CLK CLR CS MOV R2,#1 lcall _putc _putc: CLR A ;clear A MOVC A,@A+DPTR ;load data from address pointed by A+DPTR MOV R1,#8 ;Send 8 bits putc1: RRC A MOV txd_pin,C ;write next bit SETB CLK MOV R0,#BITTIM ;Wait full bit-time DJNZ R0,$ ;For DATA bit CLR CLK MOV R0,#BITTIM ;Wait full bit-time DJNZ R0,$ ;For DATA bit DJNZ R1,putc1 ;write 8 bits INC DPTR DJNZ R2,_putc SETB CS ;Set chip select line high ;CLR A MOV DPTR,#0000 ;load address from lable RET ;For STOP bit END
Punitha