labs 5 and 6 done
This commit is contained in:
50
lab8adc/Src/main.s
Normal file
50
lab8adc/Src/main.s
Normal file
@@ -0,0 +1,50 @@
|
||||
.syntax unified
|
||||
.cpu cortex-m4
|
||||
.thumb
|
||||
.section
|
||||
.text
|
||||
|
||||
.global main
|
||||
main:
|
||||
|
||||
#initialize components
|
||||
bl lcdInit
|
||||
bl keyInit
|
||||
bl timerInit
|
||||
#bl adc_init
|
||||
|
||||
#Send a single character to adjust the mode of the datalogger
|
||||
# ['1']['2']['3']['A'] |1 2 3 4 |
|
||||
# ['4']['5']['6']['B'] |5 6 7 8 |
|
||||
# ['7']['8']['9']['C'] |9 10 11 12|
|
||||
# ['*']['0']['#']['D'] |13 14 15 16|
|
||||
|
||||
|
||||
1: bl keyGetkeyNoblock
|
||||
|
||||
# '*' Buffer on/off
|
||||
cmp r0, #13
|
||||
beq buffer
|
||||
|
||||
# '#' Set interval (1-9 Seconds)
|
||||
cmp r0, #15
|
||||
beq setInterval
|
||||
|
||||
# 'B' Set Buffer size [01-99]
|
||||
cmp r0, #8
|
||||
beq setBufferSize
|
||||
|
||||
# 'D' Toggle Between displaying temperatures C or F
|
||||
cmp r0, #16
|
||||
beq toggleTemp
|
||||
|
||||
# 'A' Display Buffered results
|
||||
cmp r0, #4
|
||||
beq displayBufferedResults
|
||||
|
||||
# 'C' Continuous mode
|
||||
cmp r0, #12
|
||||
beq continuousMode
|
||||
|
||||
#loop that will finish what chosen option and then ask for another instruction
|
||||
b 1b
|
||||
31
lab8adc/Src/timer.s
Normal file
31
lab8adc/Src/timer.s
Normal file
@@ -0,0 +1,31 @@
|
||||
.syntax unified
|
||||
.cpu cortex-m4
|
||||
.thumb
|
||||
.section
|
||||
.text
|
||||
|
||||
.global timerInit
|
||||
timerInit:
|
||||
push {r0-r4, lr}
|
||||
#Alt func low reg for TIM3
|
||||
ldr r1, [r0, #AFRL_OFFSET]
|
||||
bic r1, #16, #4
|
||||
orr r1, r1, #AFRL_TIM3_CH1_EN
|
||||
str r1, [r0, #AFRL_OFFSET]
|
||||
|
||||
#Enable CCMR1 for preload and set pwm
|
||||
#Allows for the modification of the pulse
|
||||
ldr r0, =TIM3_BASE
|
||||
ldr r1, [r0, #CCMR_OFFSET]
|
||||
bfc r1, #4, #3
|
||||
mov r2, #CCMR_OCC1M_PWM
|
||||
orr r2, r2, #CCMR_OCC1PE
|
||||
orr r1, r1, r2
|
||||
str r1, [r0, #CCMR_OFFSET]
|
||||
|
||||
#Enable CCER to for TIM3 (TIC)
|
||||
#Every 10 seconds, sample
|
||||
|
||||
|
||||
pop{r0, r4}
|
||||
bx lr
|
||||
Reference in New Issue
Block a user