Anda di halaman 1dari 24

| 0+16 | 16+16 | 32+32 | 64+32 | 96+16 |!!

0
1
2
3
4

==> Chip 4 starts at 96

#!
0!
1!
2!
3!
4!

!
!
!
!
!
!

CHIP SIZE!
16!
!
16!
!
32!
!
32!
!
16!
!

STARTING VALUE!
0!
!
16!
!
32!
!
64!
!
96!
!

512!
0!
0!
0!
0!
0!

256!
0!
0!
0!
0!
0!

128!
0!
0!
0!
0!
0!

64!
0*!
0*!
0*!
1*!
1*!

| 0+64 | 64+16 | 256+256 | 512+8 | 576+64 | 640+64 | 704+64 |!


0
1
2
3
4
5
6

==> Chip 6 starts at 704

#!
0!
1!
2!
3!
4!
5!
6!

256!
0*!
0* !
1*!
0!
0!
0!
0!

CHIP SIZE!
64!
!
16!
!
256!
!
8!
!
64!
!
64!
!
64!
!

STARTING VALUE!
0!
!
64!
!
256!
!
512!
!
576!
!
640!
!
704!
!

!
!
!
!
!
!
!
!

512!
0*!
0*!
0!
1*!
1*!
1*!
1*!

128!
0!
0!
| X!
0*!
0*!
1*!
1*!

64!
0*!
1*!
X!
0*!
1*!
0*!
1*!

32!
0*!
0*!
1*!
0*!
1*!

16!
0*!
1*!
| X!
| X!
0!

8
|X
|X
X
X
|X

32!
| X!
0!
X!
0!
| X!
| X!
| X!

16!
X!
0!
X!
0!
X!
X!
X!

8
X
|X
X
0
X
X
X

IF SELECTED
/Y0/Y1/Y2/Y3/Y4/Y5/Y6/Y7
0 1 1 1 1 1 1 1
1 0 1 1 1 1 1 1
1 1 0 1 1 1 1 1
1 1 1 0 1 1 1 1
1 1 1 1 0 1 1 1
1 1 1 1 1 0 1 1
1 1 1 1 1 1 0 1
1 1 1 1 1 1 1 0
IF NOT SELECTED
1 1 1 1 1 1 1 1

A2 A1 A0
0 0 0
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0
1 1 1
x

CHIP SELECT INPUTS:


!
IF NOT 1,0,0 - NO OUTPUTS
!
IF 1,0,0 - SEE TABLE

*In an! OR gate:! !


!
AND gate:! !
11xx 010x
!
!
OPTIONS:!
!
!
!
!
!
!
!
!
!

!
!

1111 = F!
1101 = D!
1110 = E
1100 = C

= 1,! !
= 0, ! !

!
!

=0
=1

OPTIONS:!
!
!

0101 = 5
0100 = 4

*Cross compiler = Creates code for


!
processor, then runs it
*Flash = Holds code instruction for a
!
chip
*Not on MC9S12:
!
Temperature Sensor
!
Electric Buzzer
!
D --> A converter

( WE - WRITE ENABLE )

( OE - OUTPUT ENABLE )

LSTRB# = 1
R/W# = 1
PORT B = 0x3F --> 0011 111[1]
!

ADDR[0] = 1

1 1 1 = 16-bit read of an odd address (using


table)

A0 on HIGH --> Big Endian


A0 on LOW --> Little Endian
a) 8!
!
D = A13!!
(2^13) / (2^10) = 8
!
b.) Chip 0 contains HIGH order bytes
!
HIGH b/c F = D8 and G = D15
c.) Starting Address:!

A = A18!!

!
!
!
!

B = A17

0110 0000 0000 0000 0000


!
!

A17
A18!

= 0x60000

d.) Ending Address: (use A13) (after A13, all 1s)


!

0110 0011 1111 1111 1111

!
!
!

A13

= 0x63FFF

e.) Little Endian

-Normal Expanded Wide


!
C=1
!
B=1
!
A=1
-Normal Single Chip
Mode
!
C=1
!
B=0
!
A=0

-Normal Expanded Narrow, BDM Allowed

0xF80000 -->! 1111 1 0 00 0000 0000 0000


0xFFFFF -->! 1111 1 1 11 1111 1111 1111
output a low -->!1111 1xxx xxxx xxxx xxxx

*Other Possibilities*!
!
!
!

0!
0!

!
!
!

1
0

PIFn = In order to know which pin an interrupt has occurred on, this register must be read.
RDRn = This register can be used to limit the amount of current supplied to a circuit connected to the corresponding port.
DDRn = Which register needs to be configured before ever outputting a value to a certain port pin.
PERn = Connect resistor from port pin to either Vcc or Vdd.
PTIn = Detects overloads and shorts.
PPSn = This register can determine whether the pull resistor is pull-up or pull-down.

DDRH = Output -or- Inverse Input


PERH = Pull Device Enabled
PIEH = Interrupt Enabled
PPSH = Pull Down
RDRH = Reduce Drive

DDRH = bits 0 3 5 -->!!


0010 1001 = 29
!
!
!
!
!
*OUTPUT so keep the same*
*if DDRH is input:
!
0111 0111 ==> 1000 1000 = 88*
PERH = bits 6 7 -->!

1100 0000 = C0

PIEH = bits 1 2 4 -->! !

0001 0110 = 16

PPSH = bits (none) -->! !

0000 0000 = 0

RDRH = bits 0 5 -->!

0010 0001 = 21

!
!

1101 0001 --> 0xD1


!
PTH | 0xD1

!
!

0101 0110 --> 0x56


!
PTH & ~ 0x56

Default state of the input to Port H is 1

How many input capture channels are there on the 9s12?


!
--> 8

When does TOF get set?


!
--> When free running counter goes from FFFF to 0.
Give a C instruction to reset the interrupt flag of Pin 1 Port H
!
--> PIFH = | 0x02
When __ bit of CCQ is 0 --> Non-maskable is enabled

CORE CLOCK = 2 x BUS CLOCK

DIVISOR = 1024 x 2^(high bit - 1) x (low bit + 1)

RTICTL = 0x12
!
!

HIGH BIT --> 1


LOW BIT --> 2

Counter Value =

CORE CLOCK x 10^6


__________________ x mS
DIVISOR x 1000

*Round up to next whole number*

CORE CLOCK = 2 x BUS CLOCK

DIVISOR = 1024 x 2^(high bit - 1) x (low bit + 1)

RTICTL = 0x57
!
!

HIGH BIT --> 5


LOW BIT --> 7

COUNTER VALUE x DIVISOR x 1000


mS = _______________________________
CORE CLOCK x 10^6

COUNTER VALUE

Seconds =

DIVISOR
__________________
CORE CLOCK x 10^6
!

* If answer wants micro-seconds dont use 10^6 *

2^(y-1) x (y+1) =

CORE FREQUENCY
_______________________
(RTI FREQUENCY) x (1024)

HIGHEST = 0xFFFF

0x2D --> 0010 1101


!

PIN 1

* CHECK PIN NUMBERS *


!
PIN 0 -- 3 --> TCTL2
!
PIN 4 -- 7 --> TCTL1

TCTL4 = 0x1E --> 0001 1110


!
!
!
!
!
PIN 1

* CHECK PIN NUMBERS *


!
PIN 0 -- 3 --> TCTL4
!
PIN 4 -- 7 --> TCTL3

PRE

BUS CLOCK =

CORE CLOCK
____________

2
BUS CLOCK
___________

2 ^ PRE

2 ^ 16
__________

ms =

sec

(2 ^ 16) x (2 ^ PRE)
________________ x 1000
BUS CLOCK

PRE
BUS CLOCK =

CORE CLOCK
____________

Count =

Period x (TCNT Rate)


_________________

TCNT Rate =

BUS CLOCK
__________
2 ^ PRE

CORE CLOCK = BUS CLOCK x 2


PRE
OVERFLOW

COUNT =

PERIOD! !
_______! !
2!

CORE CLOCK
_______________________

2 x (2 ^ PRE) x OVERFLOW

COUNT x 2 x (2 ^ PRE) x OVERFLOW x 2


PERIOD = __________________________________

COUNT

CORE CLOCk x (10 ^ 6)

PRE
CORE CLOCK !
BUS CLOCK
TIMER CLOCK FREQUENCY = ____________! = __________
2 x (2 ^ PRE)!

(2 ^ PRE)

* Units Cancel *
PRE

1!
_______!
!
PERIOD!

!
!
!
!
! = TIMER! CLOCK FREQUENCY
!
! =
!
!
!
!
!

BUS CLOCK =

BUS CLOCK
__________
(2 ^ PRE)

CORE CLOCK
____________

COUNT =

PERIOD x [ ( BUS CLOCK x 10^6 ) / (2 ^ PRE) ]


_______________________________________
!

Solve for PRE and COUNT:


* Plug in whole numbers until answer isnt a whole number. The last whole
number is the PRESCALE value and the result is the COUNT. *

CFORC = 0x40 --> !

DELAY COUNT = BUS CLOCK x PULSE


DELAY COUNT < 256 --> ROUND UP
256 < DELAY COUNT < 1024 --> ROUND DOWN?
DELAY COUNT >> 1024 --> 0

OC7M = 0111 0111 --> 0x77


OC7D = 0011 0011 --> 0x33
* For OC7M Clears and Sets are set to 1s *
* For OC7D only Sets are set to 1s *

PTT = 0x9C --> ! !


OC7M = 0x4D -->!!
OC7D = 0x61 --> !!

1001 1100
0100 1101
0110 0001

1101 0001

0 0!
0 1!

1!
0!

1
1

PTT!

0!

BIT 7:!
!

!
!

0!
1!

Opposite PTT!

!
!

0
0
PTT

Anda mungkin juga menyukai