'{$STAMP BS2} '{$PBASIC 2.5} ' 2009 mlab.taik.fi/paja ' Receiving data from Serial port ' ---[ I/O Definitions ]--- pLED PIN 13 'DS1267 pRST PIN 0 'Pin_number_of_reset_connection. Pin 5 on DS1267 pCLK PIN 1 'Pin_number_of_clock_connection. Pin 6 on DS1267 pDQ_n PIN 2 'Pin_number_of_data(DQ)_connection. Pin 8 on DS1267 ' ---[ Variables ]--- bDSpot VAR BYTE ' ---[ Constants ]--- cSerin CON 16 cBS2 CON $100 ' x 1.0, cycle adjustment (for ms) cCycle CON 50 'Required Charge time (Cycle equation) = 5 * Resistance * Capacity 'Charge time = 5 * 10KR(10000R) * 1µF(1/1000000F) = 0.05 seconds = 50ms ' ---[ Initialization ]--- DEBUG CLS, "Receiving data from Serial port", CR ' ---[ Main Code ]--- Main: DO SERIN cSerin, 84, [bDSpot] bDSpot = bDSpot * 3 / 2 GOSUB xOutPot LOOP END ' ---[ Subroutines ]--- ' DS1267 xOutPot: '** DEBUG "xOutPut: ", DEC bDSPot0, ", ", DEC bDSPot1,CR HIGH pRST 'Take_RST_high_to_start_transfer. PULSOUT pCLK,1 'Pulse_for_stack-select_bit(don't_care). SHIFTOUT pDQ_n,pCLK,MSBFIRST,[bDSpot] 'Shiftout_pot_values. LOW pRST 'Take_RST_low_to_end_transfer. RETURN