Upload
rgsir2014
View
215
Download
0
Embed Size (px)
Citation preview
8/17/2019 Computers Sc Hardwear Management
http://slidepdf.com/reader/full/computers-sc-hardwear-management 1/3
1
ECE371 Test 2ECT1. Assume that Channel 0 of the Enhanced Capture Timer System of the MC9S12!S"#$microcontroller is %ein& used to measure the '( duty cycle of a 1 )*+ pulse ,idth modulated si&nal.
-13 points a /hat is the duty cycle percenta&e if the follo,in& conditions are present -can %e left as a
mathematical epression
The input cloc to the Timer4Control 5nit has a fre6uency of 2 M*+ Timer System Control e&ister 2 ,as initiali+ed to 00000010 /hen a risin& ed&e is detected8 a alue of 1000 he is read from re&ister TC0. /hen the net fallin& ed&e is detected8 a alue of 1032 he is detected.
Prescale is 2, divider is 4, each count is 2 µs1 KHz, T = 1ms = 500 counts010!2 " 01000 = 0!2 counts = 50 counts
#ut$ C$cle = 50%500 = 10&
-13 points % Assumin& that channel 0 is already initiali+ed to perform input capture8 ,rite an :S tocontinually perform the re6uired measurements recorded in part a -read the positie ed&e count into aaria%le pcount and read the ne&atie ed&e timer into ncount8 and chan&e the ed&e detection as needed8you don;t need to compute the duty cycle or do anythin& else to pcount and ncount.
theISR(){
if (TCTL4 & 1)//rising edge captured { TCTL4 = (TCTL4 & 0xC) ! "#
pc$unt = TC0#% ese
{ TCTL4 = (TCTL4 & 0xC) ! 1#nc$unt = TC0#
%TL'1=1#
-1# points 2. The follo,in& re&isters are used to &enerate a !/M si&nal usin& the MC9S12!S"#$microcontroller8 ,hat alues should %e set in the follo,in& statements to set the !/M si&nal to afre6uency of " )*+8 ,ith a duty cycle of 90< on the channel = output. Assume that the timer is usin& the$us Cloc ,ith a fre6uency of 2 M*+8 that you ,ill diide this %y 2 usin& an appropriate prescale option.
each time count is 1 µsP'( )eriod should *e 1%5KHz = 200 µs
//Turn $n the tier and set prescaeTSCR1 = TSCR1 ! 0x0# // *na+e TierTSCR"=0x0,# // 0+00001001 - TCR*=1. rescae=1
TIS = TIS ! 0x,0 #//Seect Channe 4. as utputs
8/17/2019 Computers Sc Hardwear Management
http://slidepdf.com/reader/full/computers-sc-hardwear-management 2/3
2
TCTL1= (TCTL1&0x2) ! 1# //xxxx xx01 3 t$gge Ch 4C = 0x10# // Seect Channe 4C2 = 0# // Cear Channe 4
TC7 = 200;
TC4 = 20; //(TC7-TC4)/TC7 = 90%
'rC2 = 0x10# // Cear Channe 4TC4 = 180 //(TC7-TC4)/TC7 = 90%
+C-10 points 3. The follo,in& data stream is receied %y a serial SC: deice8 ,hat data alue -in he isreceied8 assumin& that the sender is usin& 9>%it mode -? data %its per character and 1 parity %it.
Assumin& no errors in transmission and that the si&nal starts in @idle8 ,hat is the %inary alue of thecharacter sent
B101010011111111B
#ata = 11100101 )arit$ = 1
-" points -% Assumin& there are no errors in the transmission8 is een parity or odd parity %ein& usedeven
-" c The %us cloc that dries the SC: serial :4' system on the MC9S12!2"#$ microcontroller is a 2M*+ cloc8 and the SC: %aud rate re&isters are set as follo,s +C-.#H = 0/ +C-.# = 1000
%decimal%/ /hat actual serial data rate ,ill result from usin& these alues -leae in fractional form ifnecessary
.aud rate = 2(Hz%31divisor = 2e%313100 = 2e % 06000 7= 1250 *)s8
=.-" points a 'n the MC9S12!2"#$ SC: module8 ,hat can cause an Doerrun errorD -'8 and ho, canthis %e preented
9ot readin: the received data re:ister *e;ore the net incomin: value is received'hen the <#< ;la: 3+C0+<1, *it 5 is set, the data re:ister 3+C0 must *e read immediatel$usin: an interru)t service routine or a loo)
-" points -% 'n the MC9S12!2"#$ SC: module8 ,hat causes a Dframin& errorD -E8 and ho, can this%e preented
Cause 1> Errors in the transmission<emedies> <educe data rate, shield ca*le, use shorter ca*le, reroute ca*le, )rovide *etter )o?er;ilterin:
Cause 2> Con;i:uration error <emed$> Ensure that sender and receiver are usin: the same data size, )arit$ con;i:uration, and*it rate
8/17/2019 Computers Sc Hardwear Management
http://slidepdf.com/reader/full/computers-sc-hardwear-management 3/3
3
+P-1" points ". Assume that the S!:1 deice of the microcontroller is to %e used to send serial data to aperipheral deice. Fist the initiali+ation alues that should %e put in all the re&isters that affect thisprocess. $elo, are the conditions that should %e set up
• S!: Channel 1 is to %e used as a Master S!: deice and it should use the pins from the defaultport.
• The %it rate should %e as close as possi%le to 1008000 %its per second. -Assume that the $us
Cloc re6uency is 2 M*+
• :nterrupts re6uests should %e &enerated each time a ne, %yte is ready to %e read from the receie
re&ister.
• The SSG si&nal is to %e sent under manual control
• The first data %it should start ,ith the first risin& ed&e of SC)
(-#<< = 0##<P = 1110
.aud <ate #ivisor = (odule Cloc@ <ate%#esired .aud <ate.aud <ate #ivisor = 2 (Hz%01 (Hz = 20 = 45, 2 3+P<A1 3+PP< A 1, ;or +PP< = 4, +P< = 1+P.< = 01000001+PC<1 = 111010 3+PE=1, +PE=1, +PTE=, (+T<=1, CP-=0, CPH6=1, ++-E=0, +.E=+PC<2 = = 0 3(-# = 0
#. Assume that the S!: system of the microcontroller is to %e used to send serial data to seeral outputperipheral deices.-? points a :f the S!: $aud ate e&ister -S!:$ has %een loaded ,ith the alue 0"38 ,hat ,ill %e theresultin& %aud rate8 assume that the input cloc is a 2 M*H cloc si&nal -leae in fractional form ifnecessary
+PP< = 5, +P< = !Cloc@ divisor I 2-3J1 G -" J 1 = B
.aud <ate = (odule Cloc@ <ate%.aud <ate #ivisor = 2(Hz%B = 20,!!!D *)s
-" points % :f an S!: master sends 1000 characters to a slae S!: deice8 ,hat is the minimum time it,ould tae to do this8 if the actual %aud rate is 2 )%ps1000 char *its%character 05 millisecond = 4 seconds