Professional Documents
Culture Documents
101731
101731
void interrupt 7 Rtthandier(void)( // 30.517 Hz real time interrupt
CRGFIG = 0:80; // acknowledge by clearing RIZE
x = Poriod/240; // temperature in F
Y= GH)/2; | 17 TAR Filter y(nyety(a-2)4x (n) )/2
’
(6811 Solution 12.4
arta) With a Gain of 392, a force of 200 dynes converts directly into an A/D output of 200, To pass 0 to 10 Hz we
will havea 100Hz LPF. We will handle the offset adjustment in software,
(dynes) Vy (mV) PEI(V) AD owt
0 0 0 0
i 0s 002 1
200 10 3.92 200
‘Any low power, low noise op amp can be used to build the LPF
14) 4k
45 49.40 ae
Part b) Design the distributed network
‘Subpart b1) Show the hardware interface between a single chip 6811 slave and the network
All unused 6811 inputs must be connected to ground or +S.
slave 6811 } slave 6811 | [ slave 6811 | open collector [master a
asynchronous
PD1pDO |{ PDI PDO |[ PDIPDO | feitGupiex LPDIPDO
4,
all grounds are connected
Jonathan W. Valvano132 Solutions Manual for Real Time Embedded Systems, 2™ Edition
‘Subpart b2) The maximum baud rate fora 2 MHz 6811 is 125,000 bits/sec, the bit time is 8 us. Each frame is 1 start,
9 data bits and I stop. Each frame requires 88us to transmit, IFBit §=1 then the frame is an address from master to
slave otherwise itis a data from slave to master.
address=$31 data=$43
san0.12345 67 8siop sat0 12345 67 8x0p
U1 U iLT
Perea ake ero |
Partc) Include all the software tht will exist in each slave
‘Subpart c1) Show the software that goes inthe RAM (uninitialized on
(+ wrsszaeein REM i8 stack, local variables**¥*+©
‘Subpart 2) Show the software that goes in the EEPROM (can be different for each slave).
[+ mosvas7in EEPROM are constanter#*t¥e%+/
unsigned char Offset-0; /* easily changed to calibrate each system*/
unsigned char Address-0x34;
‘Subpattc3) Show the software that goes inthe ROM (must be the same for each slave).
[+ sTitressin ROM As exeeutable progran™**/
define Re 0x80
fdefine w 0x10
Fdetine RIE 0x20
Faetine 1 0x08,
define RE 0x04
fpragea interrupt_handler sctitan()
/* Interrupts on Zeceive data */
void Sci#lan (void) { unsigned char datar
Af(SccR1aRS)
{if (ScDRe=Address)
SCORFADRIGOEFset:) /* Send force */
else
dataescor
/* Read and ignore data frames */
,
void Ritual (void) (
i") 7% Make ritual atomic */
ScoRI=M: 74 9 bit data with T6=0 meaning data */
SCCR2-RIEHTEWRE; /* Enable SCI, interrupt on RORE */
/+ 125000 bits/sec */
7+ enabig 3/0 7/
7+ Continuous scan of channel 1 */
‘7+ Diowe1 open collector PDL */
asm(" cli") :)
void main(void) {
Ritual (
wie)
(6812 Solution 12.4
Part a) Same as 6811, except analog signal is connected to 6812 PADI
Part b) Design the distributed network
Subpart bl) Show the hardware intecface between a single chip 6812 slave and the network
All unused 6812 inputs must be connected to ground or #5
slave 6812 || slave 6812 || slave 6812] open collector [master 6812
asynchronous
psifixD || psitxD || PSUTxD | falrduptex bPSUTxD
all grounds are connectedJonathan W. Valvano 133
Subpart b2) The maximum baud rate for a 4 MHz 6812 is 250,000 bits/sec, the bit time is 4 us. Each frame is 1 start,
9 data bits and 1 stop. Each frame requires 44us to transmit. If Bit 81 then the frame is an address from master to
slave otherwise iti a data from slave to master
address=$31 data=$43
sant. 12345 67 8stop sand 12345 67 8sop
Se eee
— us —> 1
4us
Parte) Include athe software that will exist in each slave
‘Subpart eI) Show the software that goes inthe RAM (uninitialized on power up)
fo bassstienry Ratt 4s stack, Local varsableat*tsrvstsesesse/
Subpart 2) Show the software that goes inthe FEPROM (can be diferent foreach slave)
Js Nesssvesein EEPROM ate constanter*"*"#+*/
mned char Ofssee=07 /* easily changed to calibrate each systen*/
unsigned char Adcreass0x347
‘Subpart c3) Show the software that goes in the ROM (must be the same for each slave).
[x Masssnesayn som 49 executable progzaa™™*/
fectine Ro 0x80
Seetine Looes O30
Aeotine Wms) Ox40
fdetine w——ox10
Hdetine RIE 0x20
Wdefine 72 0x08
define RE 0x04
/* Interrupts on receive data */
void interrupt 20 SCiHian(void) { unsigned char data;
LE (SCIDRHERE) (
Sf (SCIDRI==Address)
SCIORL = ALDDRO‘OFEeet: /* Send @-bit force */
)
else
data = scroat; J Road snd Sgnoze data frames */
i
void Ritual (void) (
aan set J+ Nake ritual atomic */
‘SCTCRI = LOOPS+NoNSrM; /* half duplex, 9 Bit data with Té-0 meaning data */
SCICR? = RIETECRE; /* Enable SCI, interrupt on RORE
SCIED = 1, 7+ 300000 bite/see */
ATDCTL2 = 03807 /* Powerup A/D */
ATDerEA = Oxe5. Yo Bebie ROC */
AIDCTES = OxAl? 7+ Continuous scan of channel 1 */
asm cli}
void main(voia) [
Ritual (7
while)
,
{6811 Solution 12.8. Data acquisition alarm system. Part a) Resistors are 1% metal film, capacitors are ceramic or
polystyrene (high quality, nonpolarized), the filters are 2 pole Butterworth,
Jonathan W. Vaivano134 ‘Solutions Manual for Real Time Embedded Systems, 2™ Edition
instrumentation amp 100 Hz HPF
microphone]
:
7
art b) Design the interface between the 6811 signal BO and the EM relay.
a wa
: @s
sit 7406 Eww \] 1R0VAc
BO is eee
Part c) Show interface between the keypad and the 6811.
SK 1
‘:
‘Subpart dL) Show the software thet goes in the RAM (uninitialized on power up),
‘Subpart 42) Show the software that goes in the EEPROM.
7] alarm threshold
unsigned char codeLength=3; 71 cam change secret code length
unsigned char secret (3)=(3,1,2)7 // Keye which disable alarm, reverse orderJonathan W. Valvano 135
void main(void)( unsigned int iz
‘sum=0; DDRC=0; 1/ remember unused CMOS Inputs must be grounded
key-none: for (J40;iccodebength; i++) code (s}=none?
count=0;
(OP 108=02807 17 enable A/D
ADOTL*0x217 / continuous sampling of channel 2
IMSKI=0x387 11 arm both O04 and OCS
TocsetcNTe100; —// start right avay
‘rocéerowr+100;
TELGL=0x18; J] initially clear flags
asa(" c1i"):)
Subpart 44) Show the 1 kHz DAS interrupt handler:
void DAShandler (void) {
int sample=ApR1-128; // ~128 vo 127
sun-sunesanple*sampley
ocs=7005+2000; /7 2000 £ cycles in 1 ms
TFLGI~0x08; 11 acknoledge OCS
Af (eount++==1000) ( count=0,
Lf (sum>threshold) PORTB*1; // start alarm
‘sun=07))
Subpart d5) Show the keypad periodic poling interupt handler
void Keyhandler (void) { unsigned int maton, i7
yoct=10c4+40000;// #0000 £ cycles in 20 me
‘TELGI=0x10; 17, acknoledge Océ
Lf (reysenone) { 11 no key pressed last interrupt
AE(PORTC!*0x08)( // ignore if none last time and none this tine
‘swatch (PORZC) (
‘ease 0x0! ; breaks
case 0x0! break;
case 0x08 breaks
case 0x0" breaks
default: breaks)
for (imcodenength=1)4>0;i--) code(i)=code (1-2):
code (0) key?
mat cheTRUE?
for (imO7i