Presentation is loading. Please wait.

Presentation is loading. Please wait.

Processor Register Set of M16C

Similar presentations

Presentation on theme: "Processor Register Set of M16C"— Presentation transcript:

1 Processor Register Set of M16C
2 banks of general-purpose registers 4 16-bit data registers R0 - R3 Upper and lower bytes of registers R0 and R1 can be used as 8-bit registers (R0L, R0H, R1L, R1H) 2 16-bit address registers A0 & A1 Can access pairs of registers as 32-bit registers: R2R0, R3R1, A1A0 Bank 0 Data register Bank 1 PC Program Counter R0 データレジスタ アドレスレジスタ Frame base register R0 R1 R2 R3 A0 A1 FB R0H R0H R0L INTB Interrupt table register R1 R1H R1L R2 R3 Address register USP User Stack Pointer A0 ISP Interrupt Stack Pointer A1 SB Static base register Frame base register FB FLG Flag register Copyright © 2011 DSR Corporation

2 Bus Slave Selection Port enable (chip select)
Only one slave device is active and accepts requests from the bus Decode address: get the most significant bits of the address Memory Map Port enable 0x0000 Memory 1 Master Slave Slave 0x4000 Memory 2 CPU Memory 1 Memory 2 0x8000 EN EN Address Decoder “00” active 0x1000 : 0x2000 : 0x4000 : 0x5000 : The upper 2 bits Chip Select “01” active Address signal 16-bit Copyright © 2011 DSR Corporation

3 Peripheral Device: Control Register
The control registers are used to set up different modes Some features are configured by separate bits The first step in programming peripheral devices is to understand control registers of the device Example of the configuration register Counter source select bit (M16C timer) Timer A0 mode register Name Address R/W Access Size Timer A0 mode register 0x0396 8 Timer A0 register 0x0387 R 16 Counter start flag 0x0380 7 6 5 4 3 2 1 TMOD0 TMOD1 MR0 MR1 MR2 MR3 TCK0 TCK1 Specify the operating mode 00: Timer mode 01: Event counter mode 10: One-shot timer mode 11: Pulse with modulation (PWM) mode Different functions depending on the mode Copyright © 2011 DSR Corporation

4 Peripheral Devices: Using the GPIO as an Output Port
Examples of HSB16C (speaker sound generators) 1 LED is connected to port register, lights when 1 is written LED4 lights in C *((char*)0x03E0) = 0x01 M16C (microcontroller) Address 0xF000 Memory CPU Write memory instruction Program PC mov.b #1h, 03e0h 0xF120 0xF120 VCC GPIO Port Registers LED4 : On 1 1 0x03E0 1 LED3 : Off 1 Copyright © 2011 DSR Corporation

5 Peripheral Devices: Using the GPIO as an Input Port
Examples of HSB16C The value of the port register is “1” when the switch is pressed. Check SW9 in C if(*((char*)0x03E1) & 0x20 == 0x20){… } M16C Address 0xF000 CPU Memory Read memory instruction Program PC mov.b 03e1h, R1 0xF120 0xF120 VCC GPIO Port Registers SW9 : On 6 5 1 1 0x03E1 1 SW8 : Off 1 GND Copyright © 2011 DSR Corporation

6 Peripheral Device: Pull-up and Pull-down
High and low voltage values (Hi and Lo) are used to determine the ‘1’ and ‘0’ digital value Example: When the supply voltage is nearly 5v, 4 ~ 5v is Hi, 0 ~ 1v is Lo Digital signal voltage values must be in the range of Lo or Hi Pull-up and pull-down Circuit configuration for stable electrical input when connecting a switch to an input GPIO port Example of pull-up Switch ON Switch OFF Port Register Port Register Switch Switch Copyright © 2011 DSR Corporation

7 Peripheral Device: Serial I/O
Set specific value to control registers to configure I/O port Transmitter side: read value to send from special register, put it to transmit the buffer Often FIFO is used Receiver side: get received byte from buffer and put it to special register To check if send or receive complete, check the status register Transmitting side Receiver Control / status register Control / status register Transmit Buffer Receive buffer CPU CPU FIFO FIFO Transmission line 7 6 5 4 3 2 1 1 3 2 5 7 6 4 Shift register Shift register Copyright © 2011 DSR Corporation

8 Programmable Interrupt Controller (PIC)
Accept multiple interrupt requests, issue a single interrupt request to a processor Each interrupt request can be configured to be ignored Interrupt Source Register is used to determine what interrupt occurred Several PICs can be used in cascade Get interrupt information Stores information about interrupt Interrupt enable/disable PIC CPU Source Register Mask register Interrupt request 1 Interrupt request 2 Interrupt request 3 Interrupt request 4 Copyright © 2011 DSR Corporation

Download ppt "Processor Register Set of M16C"

Similar presentations

Ads by Google