Дата последнего изменения документа - 11 декабря 2006г.
Чтобы не повторяться замечу лишь, что данная прошивка отличается только командами набора номера (ATD>"SM"1; и ATD>"SM"2;) и наличием посылки "Enter" после включения микроконтроллера (без этой посылки телефон почему-то самый первый раз не звонит).
Каждая посылаемая в телефон команда начинается с 3-х волшебных байтов: 1-й байт - всегда 06, второй - длина команды, 3-й - исключающее ИЛИ первого и второго байтов. Это, конечно, касается только телефона Siemens A35.
;gsmhorn.asm v1.2 for Siemens A35 ;*** Assembler directives *************************************************************************************************** ; list p=16F84 ; List directive to define processor ; #include; Processor specific variable definitions ; __CONFIG _CP_OFF & _PWRTE_ON & _WDT_OFF & _XT_OSC ; Configuration bits LENGTH EQU 0x0E ; Length to send NEW_SIGNAL EQU 0x0F ; Bit0=1 if waiting for a new signal (to avoid sending the first 'random' LENGTH) OBYTE EQU 0x10 ; Original byte used in receive subroutine BYTE EQU 0x11 ; Byte used in send and receive subroutines BITCOUNT EQU 0x12 ; Bit counter used in send and receive subroutines COUNT1 EQU 0x13 ; Time counter used in the delay subroutine COUNT2 EQU 0x14 ; Time counter used in the delay subroutine COUNT3 EQU 0x15 INTCON EQU 0Bh ;*** Beginning of the program *********************************************************************************************** ORG 0x000 ; Processor reset vector reset GOTO init ; Go to initialization ORG 0x009 ;*** Initializations ******************************************************************************************************** init BSF STATUS,RP0 ; Select Bank 1 MOVLW b'11000101' ; прерывание по переднему фронту, Timer0 in timer mode, prescaler=1:64 assigned to timer0 MOVWF OPTION_REG ; Configure options MOVLW b'11110011' ; RB0 (interrupt) RB2 and RB3 as output, others as inputs MOVWF TRISB ; Configure PORTB MOVLW b'00011111' ; RA<0:4> as inputs MOVWF TRISA ; Configure PORTA BCF STATUS,RP0 ; Return to Bank 0 CLRF PORTB ; Initialize PORTB outputs to 0V CLRF PORTA ; Initialize PORTA outputs to 0V BSF INTCON,4 ;разрешение прерывания ;Посылаем "энтер" на всякий случай MOVLW d'13' ; CALL tx_w ; ; Дважды моргнем светодиодом BSF PORTB,3 ; RB3=5V, turn on the LED CALL delay ; Delay BCF PORTB,3 ; RB3=0V, turn off the LED CALL delay ; Delay BSF PORTB,3 ; RB3=5V, turn on the LED CALL delay ; Delay BCF PORTB,3 ; RB3=0V, turn off the LED CALL delay ; Delay thru SLEEP ;По выходе из спячки... ;зажечь светодиод BSF PORTB,3 ; RB3=5V, turn on the LED ;команда "ATH0" MOVLW d'6' ; CALL tx_w ; MOVLW d'5' ; CALL tx_w ; MOVLW d'3' ; CALL tx_w ; MOVLW d'65' ; CALL tx_w ; MOVLW d'84' ; CALL tx_w ; MOVLW d'72' ; CALL tx_w ; MOVLW d'48' ; CALL tx_w ; MOVLW d'13' ; CALL tx_w ; CALL delay ;команда ATD>"SM"1; MOVLW d'6' ; CALL tx_w ; MOVLW d'11' ; CALL tx_w ; MOVLW d'13' ; CALL tx_w ; MOVLW d'65' ; CALL tx_w ; MOVLW d'84' ; CALL tx_w ; MOVLW d'68' ; CALL tx_w ; MOVLW d'62' ; CALL tx_w ; MOVLW d'34' ; CALL tx_w ; MOVLW d'83' ; CALL tx_w ; MOVLW d'77' ; CALL tx_w ; MOVLW d'34' ; CALL tx_w ; MOVLW d'49' ; CALL tx_w ; MOVLW d'59' ; CALL tx_w ; MOVLW d'13' ; CALL tx_w ; ;выдерживаем большую паузу CALL big_delay BSF PORTB,3 ; turn on the LED ;команда ATH0 MOVLW d'6' ; CALL tx_w ; MOVLW d'5' ; CALL tx_w ; MOVLW d'3' ; CALL tx_w ; MOVLW d'65' ; CALL tx_w ; MOVLW d'84' ; CALL tx_w ; MOVLW d'72' ; CALL tx_w ; MOVLW d'48' ; CALL tx_w ; MOVLW d'13' ; CALL tx_w ; CALL delay ;команда ATD>"SM"2; MOVLW d'6' ; CALL tx_w ; MOVLW d'11' ; CALL tx_w ; MOVLW d'13' ; CALL tx_w ; MOVLW d'65' ; CALL tx_w ; MOVLW d'84' ; CALL tx_w ; MOVLW d'68' ; CALL tx_w ; MOVLW d'62' ; CALL tx_w ; MOVLW d'34' ; CALL tx_w ; MOVLW d'83' ; CALL tx_w ; MOVLW d'77' ; CALL tx_w ; MOVLW d'34' ; CALL tx_w ; MOVLW d'50' ; CALL tx_w ; MOVLW d'59' ; CALL tx_w ; MOVLW d'13' ; CALL tx_w ; ;выдерживаем большую паузу CALL big_delay BCF INTCON,1 ;сбросить бит прерывания GOTO thru ;*** Send subroutine ******************************************************************************************************** tx_w: MOVWF BYTE ; Store byte to send (W) in BYTE tx_start_bit: BCF PORTB,2 ; RB2=5V, logic 0 (start bit) NOP ; 1 Must wait 17 us for 57600 bauds NOP ; 2 NOP ; 3 NOP ; 4 NOP ; 5 NOP ; 6 Next bit will be set in 11 us from now tx_data: MOVLW 9 ; Number of bits to send + 1 MOVWF BITCOUNT ; Bit counter tx_next_bit: DECFSZ BITCOUNT,F ; Decrement counter GOTO tx_bit ; If !=0, send the bit GOTO tx_stop_bit ; Else send the stop bit tx_bit: RRF BYTE,F ; Rotate right to get next bit BTFSS STATUS,C ; If it's a zero GOTO tx_0 ; Then send a 0 GOTO tx_1 ; Else send a 1 tx_0: NOP ; To have the same delay than when it's a 1 BCF PORTB,2 ; RB2=5V, logic 0 NOP ; 1 Must wait 17 us for 57600 bauds NOP ; 2 NOP ; 3 NOP ; 4 NOP ; 5 NOP ; 6 Next bit will be set in 11 us from now GOTO tx_next_bit ; Loop tx_1: BSF PORTB,2 ; RB2=0V, logic 1 NOP ; 1 Must wait 17 us for 57600 bauds NOP ; 2 NOP ; 3 NOP ; 4 NOP ; 5 NOP ; 6 Next bit will be set in 11 us from now GOTO tx_next_bit ; Loop tx_stop_bit: NOP ; 13 Requiered for the last data bit NOP ; 14 NOP ; 15 NOP ; 16 BSF PORTB,2 ; RB2=0V, logic 1 (stop bit) NOP ; 1 Must wait 17 us for 57600 bauds NOP ; 2 NOP ; 3 NOP ; 4 NOP ; 5 NOP ; 6 NOP ; 7 NOP ; 8 NOP ; 9 NOP ; 10 NOP ; 11 NOP ; 12 NOP ; 13 NOP ; 14 NOP ; 15 The return will take the last 2 us tx_done: RETURN ; All bits send, return ;*** Delay subroutine ******************************************************************************************************* delay: MOVLW d'255' ; Delay duration MOVWF COUNT1 ; Initialize COUNT1 MOVLW d'255' ; Maximum value MOVWF COUNT2 ; Initialize COUNT2 DECFSZ COUNT2,F ; COUNT2-- GOTO $-1 ; Loop until COUNT2=0 DECFSZ COUNT1,F ; COUNT1-- GOTO $-5 ; Loop until COUNT1=0 RETURN ; Return ;*** Delay subroutine ******************************************************************************************************* big_delay: MOVLW d'140' ; Delay duration MOVWF COUNT3 ; Initialize COUNT1 mm: BSF PORTB,3 ; RB3=5V, turn on the LED CALL delay BCF PORTB,3 ; RB3=5V, turn on the LED DECFSZ COUNT3,F ; COUNT2-- GOTO mm ; Loop until COUNT2=0 RETURN ; Return ;*** End of program ********************************************************************************************************* END
Буду рад, если Вы пришлете мне свои отзывы и предложения на gsmhorn@narod.ru.
И последнее:
Автор не несет никакой ответственности за возможную порчу телефона и за любые
другие негативные последствия, возникшие вследствие использования данного
устройства.
(C) Ilya Permyakov, 2005-2009