Answered step by step
Verified Expert Solution
Question
1 Approved Answer
; GPIO base addresses of port D and E gpioFbase EQU 0 x 4 0 0 5 D 0 0 0 gpioEbase EQU 0 x
; GPIO base addresses of port D and E
gpioFbase EQU xD
gpioEbase EQU xC
gpioAbase EQU x
gpioDbase EQU xB
; PWM base adress
pwmbase EQU x
; PWM register offsets
pwmcc EQU x ; TO DO
pwmctl EQU x ; TO DO
pwmgena EQU x ; TO DO
pwmgenb EQU x ; TO DO
pwmload EQU x ; TO DO
pwmcmpa EQU x ; TO DO
pwmenable EQU x ; TO DO
; ADC base adress
adcbase EQU x
; ADC register offsets
adcactss EQU x
adcemux EQU x
adcssmux EQU xA
adcssemux EQU xB
adcssctl EQU xA
adcssfifo EQU xA
adcpssi EQU x
; GPIO offsets, least significant bits mostly
gpioData EQU x ; 'data' add relevant gpio data mask offset for masking, to read or write all values add xFC to base which is sum of all bit constants
gpioDir EQU x ; 'direction' for inp, for out, inp by default
gpioAfsel EQU x ; 'alterrnate function select' for standard gpio and gpio register used in this time, for path over selected alternate hardware function, hardware function selection is done by gpiopctl register control, default
gpioPctl EQU xC ; 'port control' see documentation
gpioLock EQU x ; to unlock xcfb shoulb be written, any other write locks back, enables write access to gpiocr
gpioCr EQU x ; 'commit' gpioafsel, pur, pdr den can only be changed with setting bit in cr only modified when unlock gpiolock
gpioAmsel EQU x ; 'analog mode select' only valid for pins of adc, set for analog,
gpioDen EQU xc ; 'digital enable'
; GPIO data mask offset constant, : in address are ussed for : bits masking
; to only write to pin of any port 'five' offset should be added to gpiodata
; to only write to pins and of any port data should be written dataregister address 'two''five' offset address remainings left unchange in output in input mode
gpioDataZero EQU x
gpioDataOne EQU x
gpioDataTwo EQU x
gpioDataThree EQU x
gpioDataFour EQU x
gpioDataFive EQU x
gpioDataSix EQU x
gpioDataSeven EQU x
; GPIO clck gating register
; default and disabled by clck blocking
; bit # for port A and # for port B should be set to enable ports
; after setting clck cycle is needed to reach port registers properly
rcgcgpio EQU xFE
rcgcpwm EQU xFE
rcgadc EQU xFE
delayData EQU x ; use this delay data as the time spent on one frequency mode
highFreq EQU xFFF ; use this value for high frequency mode
lowFreq EQU xFFF ; use this value for low frequency mode
AREA MYCODE, CODE
ALIGN
ENTRY
EXPORT main
main
NOP
BL initialize
loop
LDR Radcbase
ADD R R #adcpssi
LDR RR
ORR R R #x ; trigger ADC to start a conversion
STR RR
LDR Radcbase
ADD R #adcssfifo
LDR RR ; read bit ADC output data, the converted value is now in R
; TO DO: write the most significant bit of converted value to port D
; TO DO: make necessary changes on the PWM registers so that the buzzer keeps changing its frequency,
; also control the volume of the buzzer with ADC output value
; don't worry about the PWMbuzzer connection, they will be connected physically
B loop
initialize
; enable clck for ports A D E and F
LDR Rrcgcgpio
LDR RR
ORR R R #x ;
STR RR
NOP
NOP
NOP
LDR Rrcgcpwm ; enable PWM clock
LDR RR
ORR R R #x ; PWM
STR RR
NOP
NOP
NOP
LDR Rrcgadc ; enable ADC clock
LDR RR
ORR R R #x ; ADC
STR RR
NOP
NOP
NOP
; port A init
LDR RgpioAbase
ADD R R #gpioDir
LDR RR
ORR R R #xFF
STR RR
LDR RgpioAbase
ADD R R #gpioAfsel
LDR RR
BIC R #xFF
STR RR
LDR RgpioAbase
ADD R R #gpioDen
LDR RR
ORR R R #xFF
STR RR
; port D init
LDR RgpioDbase
ADD R R #gpioDir
LDR RR
ORR R R #xFF
STR RR
LDR RgpioDbase
ADD R R #gpioAfsel
LDR RR
BIC R #xFF
STR RR
LDR RgpioDbase
ADD R R #gpioDen
LDR RR
ORR R R #xFF
STR RR
; port F init
LDR RgpioFbase
ADD R R #gpioDir
LDR RR
ORR R R #xFF
STR RR
LDR RgpioFbase
ADD R R #gpioAfsel
LDR RR
ORR R #x ; set for PWM
STR RR
LDR RgpioFbase
ADD R R #gpioPctl
LDR RR
ORR R #x ; write to select PWM from alternate functions
STR RR
LDR RgpioFbase
ADD R R #gpioDen
LDR RR
ORR R R #xFF
STR RR
; port E init
LDR RgpioEbase
ADD R R #gpioAfsel
LDR RR
ORR R #x
STR RR
LDR RgpioEbase
ADD R R #gpioDen
LDR RR
BIC R R #x
STR RR
LDR RgpioEbase
ADD R R #gpioAmsel
LDR RR
ORR R R #x
STR RR
; ADC init
LDR Radcbase
ADD R R #adcactss ; bit field :SS enable, SS enable, SS enable, SS enable
LDR RR
BIC R R #x
STR RR
LDR Radcbase
ADD R R #adcemux ; bit field : SSxprocessor triggeredadcpssiSS trigger SS trigger, SS trigger
LDR RR
BIC R R #xF
STR RR
LDR Radcbase
ADD R R #adcssmux ; bit field : SS input select if adcssemux bit is set, there is an offset of
LDR RR
BIC R R #xF
STR RR
LDR Radcbase
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started