[bascom] 8051: How to evaluate Clock and Data; I/O


From "Patrick L'huillier" <Patrick.Lhuillier@planet-interkom.de>
Date Sun, 24 Jun 2001 12:05:19 +0200

Hi Bascom8051 users
it is probably one of the standard cases a microcontroller has to manage, but I never connected another input device to my hobby project other than a DCF antenna.
 
I've got a clock which could be connected to the PC parallel printer port but do not need it anymore. I decided to use this clock on one of my projects to get the time & date information.
I have all information available to interface to this clock but have problems to understand or implement the interrupt routine to access the data.
 
A "wake up" signal has to be send to the clock which is no problem. If the clock has recognized the call, it will begin
to transmit the data.

The radio clock uses Paper Out as the data line and Select as the clock
line to transmit data with a clock of 2.5 milliseconds per bit.
Timing graph:

 '           .    .    .           .    .    .           .    .    .
 '             0.2.0.2     2 ms      0.2.0.2     2 ms      0.2.0.2
 '           .    .    .           .    .    .           .    .    .
 '         ------------+           .    .    +---------------------+
 ' Select    .    .    ¦           .    .    ¦           .    .    ¦
 '           .    .    ¦           .    .    ¦           .    .    ¦
 '           .    .    ¦           .    .    ¦           .    .    ¦
 '           .    .    ¦           .    .    ¦           .    .    ¦
 '           .    .    +---------------------+           .    .    +--
 '           .    .    .           .    .    .           .    .    .
 '           .    .    .           .    .    .           .    .    .
 '           ---------------------------------------------------------
 ' Paper Out .    .    .           .    .    .           .    .    .
 '           ¦ 0 ¦         Bit 0   ¦ 0 ¦         Bit 1   ¦ 0 ¦
 '           +--------------------------------------------------------
 '
 
I thought if the "select" line goes low or high the data on the "Paper-Out" line is valid. As there is nothing connected to the INT0 and INT1 ports of the 89C2051 I thought I use an inverter (7414) and connect the clock ("select" of the printer port) to the both interrupt pins to get an interrupt on falling and rising edge of the clock signal:
 
Set Tcon.0
Set Tcon.2    'triggered by falling edge
 Enable Int0
 Enable Int1
 
 On Int0 Dcf77_daten
 On Int1 Dcf77_dat1
 
Every time an interrupt occur, I read the data line and increase a counter (incr i) until all 69 bits of the time stamp have been received (main program is just Do loop until i=69):
 
Dcf77_dat1:
Dcf_array(i) = Dcf77_daten
Incr I
Return
 
The data I got so far is not correct - I think the way I access the data it is totally wrong.
 
What would be the normal way to evaluate this data? It is more or less the same problem to access a PC-keyboard when connecting it to a microcontroller application.
 
Thank you very much
 
Regards
Patrick