Programmable Package SG-8018CA(SG7050C) 0.67M~170M
Memory chip
; PIC16F877 Assembly Code for DS1302 Real-Time Clock Interface ; This code provides a basic structure for initializing and communicating with the DS1302 RTC module. ; It includes functions for setting time, reading time, and handling data transfer. #include CBLOCK 20H SEC ; Seconds MIN ; Minutes HOU ; Hours DATE ; Date MON ; Month DAY ; Day YERR ; Year DDD ; Write enable bit TIME_TX ; 1302 transmit register TIME_RX ; 1302 receive register COUNT1 ; Counter 1 COUNT2 ; Counter 2 DELAY1 DELAY2 ENDC ;========================================== ; DS1302 Subroutine Description ; DS1302INI: Initialize DS1302, disable RST, set charge method ; SET_TIME: Send 7 data bytes to set time ; GET_TIME: Receive 7 data bytes to display time ; TIME_WRITE_1: Write one byte to 1602 ; TIME_READ_1: Read one byte from 1602 ;========================================== ;================= DS1302 Definitions ================== #define I_O PORTC, 7 ; DS1302 I/O pin #define SCLK PORTC, 6 ; DS1302 clock pin #define RST PORTA, 0 ; DS1302 enable pin #define RX_ADD 40H ; Save received 7 data #define TX_ADD 20H ; Start saving 7 time data to be written BANK1 MACRO BSF STATUS, RP0 ENDM BANK0 MACRO BCF STATUS, RP0 ENDM ;=============================================== ORG 00H NOP GOTO MAIN MAIN CALL CLR_RAM ; Clear RAM CALL PORT_INI ; Initialize ports CALL DS1302_INI ; Initialize DS1302 CALL SET_TIME ; Set time CALL GET_TIME ; Get time GOTO $ ; Write seconds, can write any 7 time data, single byte MOVLW '10000000' MOVWF TIME_TX BSF RST CALL CMD MOVLW '00100101' MOVWF TIME_TX CALL CMD BCF RST ; Countdown, can read any 7 time, single byte MOVLW '10000001' MOVWF TIME_TX BSF RST CALL CMD CALL TIME_READ_1 BCF RST GOTO $ ;************************************************* * ; DS1302_INI: Subroutine ; Purpose: Initialize DS1302, first disable RST, allow write enable ;************************************************* * DS1302_INI BCF SCLK BCF RST ; First disable MOVLW '10001110' ; Write enable register MOVWF TIME_TX BSF RST CALL CMD MOVLW '0' ; Enable write MOVWF TIME_TX CALL CMD ; Send one byte of data BCF RST RETURN ; Setting the charging method is not set RETURN ;************************************************* * ; SET_TIME ; Purpose: Input 7 data at once to set time, while enabling write register ; Burst mode write, must write 8 data, not 7 ; INPUT: 8 data to be set has been written to the 8 bytes starting from TIME_TX_ADD ;************************************************* * SET_TIME MOVLW '10111110' ; Flag MOVWF TIME_TX BSF RST CALL CMD MOVLW TX_ADD ; Start address of transmitted data MOVWF FSR MOVLW '8' MOVWF COUNT2 TW1 MOVF INDF, W MOVWF TIME_TX CALL CMD INCF FSR, F DECFSZ COUNT2, F GOTO TW1 BCF RST RETURN ;*********************************************** ; GET_TIME ; Purpose: Accept 7 bytes of time data at once, burst mode read ; INPUT: NONE ; OUTPUT: Save 7 time data in 7 registers starting with TIME_RX_ADD ;*********************************************** GET_TIME MOVLW '10111111' MOVWF TIME_TX BSF RST CALL CMD MOVLW RX_ADD ; Start address of saved data MOVWF FSR MOVLW '7' MOVWF COUNT2 TR2 CALL TIME_READ_1 MOVF TIME_RX, W MOVWF INDF INCF FSR, F DECFSZ COUNT2, F GOTO TR2 BCF RST RETURN ;************************************************ ; TIME_WRITE_1 ; Purpose: Send one byte of data at a time, used to send DS1302 control word or data ; INPUT: TIME_TX ;************************************************ CMD MOVLW '8' MOVWF COUNT1 TLOP BCF I_O ; Initial value is low BCF SCLK BTFSC TIME_TX, 0 BSF I_O RRWF TIME_TX, F BSF SCLK ; Send data on high level DECFSZ COUNT1, F GOTO TLOP BCF SCLK ; Recovery RETURN ;************************************************ ; TIME_READ_1 ; Purpose: Read one byte of data from DS1302 ; INPUT: NONE ; OUTPUT: Received data is saved in TIME_RX ; Principle: Receive data on falling edge of SCLK, low byte first, based on I_O ; The level is taken with carry and shifted right without carry ;*********************************************** TIME_READ_1 BANK1 BSF TRISC, 7 ; I_O is input BANK0 MOVLW '8' MOVWF COUNT1 ; Read 8 bits TR1 BCF SCLK ; Falling edge read BCF STATUS, C BTFSC I_O BSF STATUS, C RRWF TIME_RX, F BSF SCLK ; Restore high level DECFSZ COUNT1, F GOTO TR1 BANK1 BCF TRISC, 7 ; Output BANK0 BCF SCLK ; Recovery RETURN ;=============================================== PORT_INI BANK1 MOVLW 0x00 MOVWF TRISC MOVLW 0x00 MOVWF TRISB MOVLW 0x00 MOVWF ADCON1 MOVLW 0x00 MOVWF TRISA BANK0 MOVLW 0x18 MOVWF 20H MOVLW 0x19 MOVWF 21H MOVLW 0x05 MOVWF 22H MOVLW 0x13 MOVWF 23H MOVLW 0x14 MOVWF 24H MOVLW 0x15 MOVWF 25H MOVLW 0x16 MOVWF 26H RETURN ;=========================== CLR_RAM MOVLW 0x20 MOVWF FSR LOOP CLRF INDF INCFSR FSR, F BTFSS FSR, 7 GOTO LOOP RETURN ;=========================== END

Silicon TVS / TSS

Silicon TVS / TSS:

Diode TVS (Transient Voltage Suppressor), also known as Transient suppression diodes, is widely used a new type of high efficient circuit protection device, it has a fast response time (the nanosecond) and high surge absorbing ability.When it ends of stand moments of high energy shock, TVS can bring the two ends at high rate from high impedance to a low impedance between impedance values, to absorb a large current moment, put it at both ends of the voltage restraint on a predetermined value, thus protecting the back of the circuit components are not affected by the impact of the transient high pressure spikes.

Silicon TVS Transient Voltage Suppresso,Silicon TSS Transient Voltage Suppresso

YANGZHOU POSITIONING TECH CO., LTD. , https://www.yzpst.com