-
Notifications
You must be signed in to change notification settings - Fork 0
/
bsp.s43
74 lines (64 loc) · 3.53 KB
/
bsp.s43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "bsp.h"
MODULE BSP
PUBLIC GPIOconfig,TIMERconfig,ADCconfig,ADCLabconfig
PUBLIC Stop_Timer
EXTERN StartTimer,StopTimer,EnableTAIFG,DisableTAIFG,ClearTAIFG
EXTERN main,PBs_handler,TimerA_ISR,Garbage,Task3state
RSEG CODE
;-----------------------------------------------------------------------------
; GPIO congiguration
;-----------------------------------------------------------------------------
GPIOconfig mov.w #WDTPW+WDTHOLD,&WDTCTL ; hold watchdog timer
; PushButtons Setup
bic.b #0xF3,PBsArrPortSel ; 1111 0111 -> everything but 1.3 are I/O
bis.b #0x0C,PBsArrPortSel ; 0000 1100 -> Set P1.3 as A3 input for ADC
; P1.2 PWM Output
bis.b #0x0C,PBsArrPortDir
bis.b #0x03,PBsArrIntEdgeSel ; pull-up - 0000 0011
bic.b #0x10,PBsArrIntEdgeSel ; pull-down - 0001 0000
bis.b #0x17,PBsArrIntEn ; enable interrupts fo PB0,PB1,PB2
bic.b #0x13,PBsArrIntPend ; clear pending interrupts
; LCD
bic.b #0xE0, LCDCMDSEL ; Set LCD CMD lines to I/O
bis.b #0xE0, LCDCMDDIR ; Set LCD CMD lines to OUTPUT
bic.b #0xFF, LCDDataSEL ; Set LCD data byte to I/O
bis.b #0xFF, LCDDataDIR ; Set LCD data byte to OUTPUT
ret
;-------------------------------------------------------------------------------------
; Timers congiguration
;-------------------------------------------------------------------------------------
TIMERconfig cmp #0,Task3state
jeq Exit
MOV.W #TACLR,Timer_A1_CTL ; Clear Timer A
MOV.W #TASSEL_2+MC_1,Timer_A1_CTL ; SMCLK,Up Mode
cmp #1,Task3state
jeq Freq1K
cmp #2,Task3state
jeq Freq3K
Freq1K MOV.W #1048,Timer_A_CC0_Reg
jmp Exit
Freq3K MOV.W #349,Timer_A_CC0_Reg
jmp Exit
Exit RET
Stop_Timer BIC.W #TASSEL_2+MC_3,Timer_A1_CTL ;Stop Timer
RET
;--------------------------------------------------------------------------------------
; ADC congiguration
;--------------------------------------------------------------------------------------
ADCconfig bic.w #ENC,ADC_CTL0 ;modifiable only when enc=0
mov.w #ADC_Cycles+ADC_ON+ADC_IE,ADC_CTL0 ;sample&hold=16 cycles,ADC10 on,enable interupt
mov.w #INCH_3, ADC_CTL1 ;input channel 3
ret
;--------------------------------------------------------------------------------------
; ADC LAB congiguration
;--------------------------------------------------------------------------------------
ADCLabconfig
; bic.w #ENC,ADC_CTL0
; mov.w #ADC_Cycles+ADC_ON, ADC_CTL0
; mov.w #SHP+CSTARTADD_3, ADC_CTL1
; mov.b #INCH_3, ADC_MEM_CTL
; mov.w #ADC_MEM3IE, ADC_IE
; bis.b #0x08, &P6SEL
ret
ENDMOD
END