??? 08/14/04 15:13 Read: times |
#75920 - Stuck on the event timer |
Thanks to all who responded to my last thread it was a great help. What I figured out from that is I want this setup on my AT89C52 chip -
Timer0 = RTC Timer1 = Baud rate generator Timer2 = Event counter My goal is to be able to set Timer0 through the serial port plus time how long it takes and thats where I'm stuck, once Timer0 is interrupted by RI being set how do I, start Timer2 counting, recieve data from the serial port, stop Timer2, calculate how long it took to recieve the data, return to RTC? My thoughts so far: ORG 0023H PUSH ACC PUSH PSW CLR TR0 ;Stop Timer 0 MOV SM1,#10h ;Set serial mode 1 MOV TMOD,#20h ;Timer 1 in Auto-reload mode MOV TH1,#0FDh ;Reload value for 19200 baud @ 11.059 Mhz SETB TR1 ;Turn on timer 1 MOV A,PCON ;Get current value of PCON SFR SETB ACC.7 ;Set the SMOD bit MOV PCON,A ;Update the value of the PCON SFR MOV A,SBUF CJNE A,#'A',EXIT_SI ;If Acc not= A exit and start again CLR TI ;Clear TI MOV SBUF,#'Z' ;Move Z into SBUF JNB TI,$ ;Pause until TI bit is set (sending back conformation of RCV) JNB RI,$ ;Pause until RI bit is set (Awaiting next transmission) CLR C/T2 ;Make Timer 2 an interval counter MOV TH2,#HIGH(RESET_VALUE) ;Set the high byte of the reset value MOV TL2,#LOW(RESET_VALUE) ;Set the low byte of the reset value SETB TR2 ;total mental blank here :) |
Topic | Author | Date |
Stuck on the event timer | 01/01/70 00:00 | |
RE: Stuck on the event timer | 01/01/70 00:00 | |
RE: Stuck on the event timer | 01/01/70 00:00 | |
RE: Stuck on the event timer | 01/01/70 00:00 | |
RE: Stuck on the event timer | 01/01/70 00:00 | |
RE: Stuck on the event timer | 01/01/70 00:00 | |
RE: Stuck on the event timer | 01/01/70 00:00 | |
RE: Stuck on the event timer![]() | 01/01/70 00:00 |