⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dc550_hwinit.s43

📁 一款经典的数字电话设计资料
💻 S43
字号:
;*****************************************************************************;
;*  CONFIDENTIAL                                                             *;
;*  Sigpro Copyright 2003, All rights reserved                               *;
;*****************************************************************************;
;*  CLIENT:  Telematrix                                                      *;
;*  PROJECT: DC550 Digital Centrex Phone                                     *;
;*  FILE:    dc550_hwinit.s43                                                *;
;*****************************************************************************;
;*  This file contains the functions used to initialize the MSP430 hardware  *;
;*****************************************************************************;

#include <msp430x14x.h>
#define __ASSEMBLY__
#include "dc550_local.h"

	NAME	dc550_hwinit(16)
	RSEG	CODE(1)
	PUBLIC	hwinit_init_adc12
	PUBLIC	hwinit_init_clock
	PUBLIC	hwinit_init_cpu
	PUBLIC	hwinit_init_misc
	PUBLIC	hwinit_init_portpins
	PUBLIC	hwinit_init_timera
	PUBLIC	hwinit_init_usart
	PUBLIC	hwinit_activate_watchdog
	PUBLIC	hwinit_reset_watchdog
	PUBLIC  i2c_bitDelay
	EXTERN	?CL430_1_26_L08
	

;******************************************************************************
;*  CONSTANTS
;******************************************************************************
INT_TIME	equ	192		; 32 kHz (was 250 for 8mHz xtal)


	RSEG	CODE

;******************************************************************************
;*  FUNCTION: void hwinit_init_cpu(void)
;******************************************************************************
;*  DESCRIPTION:
;*  Performs various initialization tasks on the 16-bit CPU in the MSP430
;******************************************************************************
hwinit_init_cpu:
; PKW: Commenting out the reset of the stackpointer because the CSTARTUP
;      routine already does a reset.
;RESET	mov.w	#0A00h,SP		; Initialize 'F149 stackpointer
StopWDT	mov.w	#WDTPW+WDTHOLD,&WDTCTL	; Stop WDT
	RET


;******************************************************************************
;*  FUNCTION: void hwinit_init_clock(void)
;******************************************************************************
;*  DESCRIPTION:
;*  Initializes the external oscillator crystal
;******************************************************************************
hwinit_init_clock:
;	jmp	clk_ok
#if TDB
        bic.b	#XT2OFF,&BCSCTL1	; turn on XT2 crystal
#else
	bis.b	#XTS,&BCSCTL1		; LFXT1 set for high frequency
#endif
	
	mov.b	&BCSCTL1,r15		;????
	mov.b	&BCSCTL2,r14		;????
	mov.b	&IFG1,r13		;????

wait_HF_oscillator			; This loop will wait till
	BIC.b	#OFIFG,&IFG1		; high frequency crystal is stable
	BIT.b	#OFIFG,&IFG1
	JZ	L2
	
;	wait for crystal stable

	push	#0FFFFh	; Delay for crystal start
L1	dec	0(SP)
	jnz	L1
	incd	SP
	

	BIT.b	#OFIFG,&IFG1
	JnZ	wait_HF_oscillator

					; Then set MCLK same as XT2CLK
L2:					; and SMCLK = XT2CLK/4
#if TDB
	mov.b	#(SELS+SELM1),&BCSCTL2		; use XT2CLK
#else 
	mov.b	#(SELS+SELM1+SELM0),&BCSCTL2	; use LFXT1 as clock source
#endif 
	RET

	
;******************************************************************************
;*  FUNCTION: void hwinit_init_timera(void)
;******************************************************************************
;*  DESCRIPTION:
;*  Initializes Timer A on the MSP430, which uses the clock from the external
;*  oscillator crystal
;******************************************************************************
hwinit_init_timera:
	mov	#(INT_TIME-1),&TACCR0
	mov	#00090h,&TACCTL0	; set outmode 4 for toggle, Interrupt
					; enabled
	mov	#(INT_TIME/2),&TACCR1	; A/D convert trigger
	mov	#000e0h,&TACCTL1	; is TIMER_A.OUT1

#if TDB
	mov	#00214h,&TACTL		;start TIMER_A up mode, select SMCLK as input clock
#else
	mov	#00114h,&TACTL		; start TIMER_A up mode, select ACLK as
#endif
					; input clock
	RET		

	
;******************************************************************************
;*  FUNCTION: void hwinit_init_adc12(void)
;******************************************************************************
;*  DESCRIPTION:
;*  Initializes the ADC, which is used by the modem
;******************************************************************************
hwinit_init_adc12:
	clr	&ADC12CTL0		;make sure ENC cleared (will be after
					;reset)
	mov.b	#00000h,&ADC12MCTL0	;channel a0, refs = Vcc and Vss
	mov	#00504h,&ADC12CTL1	;repeat single channel, 
					;timer A inverted is sample_input
					;signal
;	mov	#02210h,&ADC12CTL0	;select 2*4*ADC12CLK for sampling time
	mov	#00010h,&ADC12CTL0	;Sample&Hold Time 0
					;Sample&Hold Time 1
					;Multiple Sample&Hold OFF
					;reference voltage is off
					;ADC12 module is switched on
					;Interrupt at the end of every ADC
					;conversion
	mov	#00000h,&ADC12IE	;disable interrupt
					;everytime each buffer memory has ADC
					;data, clear automatically
	bis	#00002h,&ADC12CTL0	;enable conversion
	RET		

	
;******************************************************************************
;*  FUNCTION: void hwinit_init_usart(void)
;******************************************************************************
;*  DESCRIPTION:
;*  Initializes the USART port, which is used for debugging
;******************************************************************************
hwinit_init_usart:
	mov.b	#0,&U0MCTL
	mov.b	#080h,&U0BR0		; 6.144mhz/9600 (was 41h for 8mHz xtal)
	mov.b	#002h,&U0BR1		; (was 3)
	bis.b	#030h,&P3SEL		; select RXD and TXD at port 3
	bis.b	#010h,&P3DIR		; port 3 TXD output
	bis.b	#0C0h,&ME1		; enable USART modules
	mov.b	#SPB+CHAR,&U0CTL	; USART control reg - two stop bits, 8 data bits
#if TDB
	mov.b	#SSEL1,&U0TCTL		; transmit control reg SMCLK
#else
	mov.b	#SSEL0,&U0TCTL		; transmit control reg ACLK
#endif
	mov.b	#0,&U0RCTL		; receive control reg
	
	RET		

	
;******************************************************************************
;*  FUNCTION: void hwinit_init_portpins(void)
;******************************************************************************
;*  DESCRIPTION:
;*  Initializes the various port pins used for input and output
;******************************************************************************
hwinit_init_portpins:
	mov.b	#000h,&P1DIR		; Port 1 all input

	;; leave watchdog disabled for now
	mov.b	#0fdh,&P4DIR		; Port 4 all output
	mov.b	#000h,&P4OUT            ; digital pot de-selected
	mov.b	#001h,&P4SEL		; select TB0
	
#if TDB
	mov.b	#001h,&P6SEL		; P6.0 is analog input
#else
	mov.b	#001h,&P6SEL		; P6.1 is analog input, proto board=002h
#endif
	
	
	mov.b	#0ffh,&P5DIR		; Port 5 all output
	mov.b	#000h,&P5OUT	
	
	mov.b	#0ffh,&P2DIR		; Port 2 all output
	mov.b	#000h,&P2OUT	
	
	RET		


;******************************************************************************
;*  FUNCTION: void hwinit_init_misc(void)
;******************************************************************************
;*  DESCRIPTION:
;*  This function performs miscellaneous hardware initialization.  It can be
;*  assumed that this function will be called immediately before the main
;*  loop.
;******************************************************************************
hwinit_init_misc:
	eint				; enable interrupts	
	MOV.B	#0,&33			; P1OUT = 0
	RET		


;******************************************************************************
;*  FUNCTION: void hwinit_activate_watchdog(void)
;******************************************************************************
;*  DESCRIPTION:
;*  This function activates the watchdog timer by setting the pin that
;*  controls the watchdog to output.  The watchdog is activated the first
;*  time the pin is hit.  This is a somewhat dirty way of getting this to
;*  work, but it's functional.
;******************************************************************************
hwinit_activate_watchdog:
	bis.b	#002h,&P4DIR		; Set watchdog timer port to output
        RET
        

;******************************************************************************
;*  FUNCTION: void hwinit_reset_watchdog(void)
;******************************************************************************
;*  DESCRIPTION:
;*  This function resets the watchdog timer.  It must be called periodically
;*  during the normal execution of the software.
;******************************************************************************
hwinit_reset_watchdog:
  	bis.b	#002h,&P4OUT		; HIT_WDT high
	bic.b	#002h,&P4OUT		; HIT_WDT low
	RET		

;******************************************************************************
;*  FUNCTION: void i2c_bitDelay(void)
;******************************************************************************
;*  DESCRIPTION:
;*  This function waits one bit delay for the i2c bus.  This is about 5 us.
;******************************************************************************
i2c_bitDelay:
        push    #6                      ;  4 cycles
i2c_0:  dec     0(sp)                   ;   (4+2) * 6 cycles
        jnz     i2c_0                   ;=36 cycles
        incd    sp                      ;  1 cycle
        ret                             ;  2 cycles


	END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -