Top Banner
WRES3315 Embedded Programming Assignment 1 Comparison between FREESCALE MC9S08AW60 and RENESAS R8C MCU Name: Lim Jee Sing Matrik No: WEK 090031
21

WRES3315 Assignment 1_WEK090031

Oct 22, 2014

Download

Documents

ah_sing_2
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: WRES3315 Assignment 1_WEK090031

WRES3315 Embedded Programming

Assignment 1

Comparison between FREESCALE MC9S08AW60 and RENESAS R8C MCU

Name: Lim Jee Sing

Matrik No: WEK 090031

Page 2: WRES3315 Assignment 1_WEK090031

ContentsWRES3315 Embedded Programming..............................................................................................1

MCU Block Diagram and Its Embedded Module.............................................................................3

FREESCALE 68HCS08 MCU..........................................................................................................3

Block Diagram.........................................................................................................................3

List of Embedded Modules.....................................................................................................4

RENESAS R8C..............................................................................................................................5

Block Diagram.........................................................................................................................5

List of Embedded Modules.....................................................................................................6

MCU Architecture Comparison.......................................................................................................7

FREESCALE MC9S08AW60 CPU Register.....................................................................................7

RENESAS R8C CPU Register.........................................................................................................9

MCU Memory Map.......................................................................................................................11

FREESCALE MC9S08AW60........................................................................................................11

RENESAS R8C............................................................................................................................12

Addressing Mode..........................................................................................................................13

FREESCALE MC9S08AW60........................................................................................................13

RENESAS R8C............................................................................................................................13

MCU Instruction Set.....................................................................................................................15

FREESCALE MC9S08AW60........................................................................................................15

RENESAS R8C............................................................................................................................17

Reference:....................................................................................................................................18

Page 3: WRES3315 Assignment 1_WEK090031

MCU Block Diagram and Its Embedded Module

FREESCALE 68HCS08 MCU

Block Diagram

Page 4: WRES3315 Assignment 1_WEK090031

MC9S08AW60 Series Block Diagram

List of Embedded Modules

1. Analog-to-Digital Converter 16 channel, 10 bit

2. Internal Clock Generator3. Inter-Integrated Circuit4. Keyboard Interrupt

8 channel5. Serial Communications Interface6. Serial Peripheral Interface7. Two 16-bit Timer Pulse-Width Modulator

1 with 6-channel 1 with 2-channel

8. Central Processing Unit9. Debug Module10. Voltage Regulator11. User RAM12. User Flash

Page 5: WRES3315 Assignment 1_WEK090031

RENESAS R8C

Block Diagram

R8C BLOCK DIAGRAM

Page 6: WRES3315 Assignment 1_WEK090031

List of Embedded Modules1. Analog-to-Digital Converter

10 bits x 12 channels2. System Clock Generator3. Timer

3 x 8 bit 1 x 16 bit

4. Watchdog Timer 15 bits

5. Clock Synchronous Serial I/O 8 bits x 1 channel

6. UART (Universal Asynchronous Receiver/Transmitter) 8 bits x 1 channel

7. Central Processing Unit8. User ROM/RAM

Page 7: WRES3315 Assignment 1_WEK090031

MCU Architecture Comparison FREESCALE 68HSC08 RENESAS R8C

CPU Architecture 8-bit 16-bitCPU Speed 48 Mhz 20MhzOperating Voltage 2.7-5.5V 3-5.5VAddress Space 20-bit(1Mbyte) 16-bit (64Kbyte)

FREESCALE MC9S08AW60 CPU Register

MC9S08AW60 CPU Register

Page 8: WRES3315 Assignment 1_WEK090031

There are total of 5 register in MCU:

i) Accumulator (A)- A general purpose 8-bit register.- Generally, the operand and result of arithmetic and logical operations are

stored here.- The content of accumulator can be loaded/stored to memory using various

addressing mode.- RESET has no effect on the contents of accumulator.

ii) Index Register (H:X)- A 16-bit register which actually made of two separate 8-bit register (H:X).- Act as address pointer, where H holds the upper byte of an address, and X holds

the lower byte of an address.- All indexed addressing mode use the value of Index Register as an index

reference pointer.- X also can be used as a general purpose 8-bit register to store data.- RESET will force H 0x00, but has no effect on the content of X.

iii) Stack Pointer (SP)- A 16-bit address pointer registers that point at the next available location on the

stack.- Stack is located at the address space where RAM reside, and take up the size of

amount available on RAM.- Stack is used to save the return address of subroutine call, the return address

and CPU register during interrupt and local variables.- RESET force the SP to 0x00FF.

iv) Program Counter (PC)- A 16-bit register that contain the address of next instruction or operand to be

fetch.- During normal execution, the value of PC automatically increments to the next

sequential address after an instruction or operand is fetched.- Change-of-flow can occur when instruction such as jump, branch, interrupt and

return , load the program counter with an address other than that of next sequential address.

- RESET force the PC to 0xFFFF,0xFFFE, the address which contain the first instruction to be executed after reset.

Page 9: WRES3315 Assignment 1_WEK090031

v) Condition Code Register- A 8-bit register that contain the interrupt mask, and five flags that indicate the

result of the instruction just executed.- Bit 5 and 6 are permanently set to 1.

RENESAS R8C CPU Register

RENESAS R8C CPU Register

Page 10: WRES3315 Assignment 1_WEK090031

There are 8 kind of register in this MCU:

i) Data Register (R0, R1, R2 and R3)- R0 to R3 are 16-bit registers used for transfer, arithmetic and logic operations.- R0 and R1 can be split into high order bit and low order bit to be used

separately as 8-bit data registers.- R2 can be combined with R0 to be used as 32-bit data register (R2R0), and this

same goes to R3R1.

ii) Address Register (A0 and A1)- Both are 16-bit register used for indirect addressing and relative addressing.- Can also be used as data register for transfer, arithmetic and logic operation.- A0 can be combined with A1 to be used as 32-bit address register.

iii) Frame Base Register (FB)- A 16-bit register used for frame base relative addressing.

iv) Interrupt Table Register (INTB)- A 20-bit register indicates the start address of an interrupt vector table.

v) Program Counter (PC)- A 20-bit register indicate the address of next instruction or operand to be

fetched.

vi) User Stack Pointer (USP) and Interrupt Stack Pointer (ISP)- Both are 16-bit stack pointer.

vii) Static Base Register (SB)- A 16-bit register for static base relative addressing.

viii) Flag Register (FLG)- 11-bit register indicating the CPU state.

Page 11: WRES3315 Assignment 1_WEK090031

MCU Memory Map

FREESCALE MC9S08AW60

MC9S08AW60 Memory Map

The figure shows the memory map of MC9S08AW60. There is RAM, non-volatile FLASH memory, I/O, and control/status registers mapped to the address space. The registers are divided into 3 groups:

1) Direct page register ($0000 - $006F)2) High page register ($1800 - $185F)3) Non-volatile page register ($FFB0 - $FFBF)

Page 12: WRES3315 Assignment 1_WEK090031

RENESAS R8C

RENESAS R8C Memory Map

The MCU provide 1-Mbyte of address space, $00000 – SFFFFF, 20-bit of addressing. The internal ROM is used to store program ROM. The $0FFDC - $0FFFF is allocated for fixed interrupt vector table. The internal ROM for data flash is allocated at $02000 - $02FFF. The internal RAM is allocated starting from $00400, depending on the size of RAM. RAM is used to store data, calling subroutines and stack when interrupt is issued. Special Function Registers (SFR) are allocated to $00000 – $002FF, which include the peripheral function control registers.

All the space which have nothing allocated to it, are reserved area and cannot be accessed by users.

Page 13: WRES3315 Assignment 1_WEK090031

Addressing ModeAddressing mode define the way CPU accesses operands and data.

Comparing the 2 MCU, FREESCALE MC9S08AW60 and RENESAS R8C, it shows that RENESAS R8C having a bigger addressing space, and has more designed register to support more kind of addressing mode, e.g. the Frame Base addressing mode.

FREESCALE MC9S08AW60In all HCS08, all memory, status and control registers, and input/output ports share a single 64-Kbyte linear address space; hence a 16-bit binary address is sufficient to uniquely identify any memory location.

This is convenient to developer because the same instruction used to access RAM can also be used to access other I/O ports, control and status register.

RENESAS R8CThere are varieties of addressing set in RENESAS R8C:

1) General Instruction Addressing- This addressing type is used to access the memory area within $00000 - $0FFFF.

2) Special Instruction Addressing- This addressing type is used to access the memory area within $00000 - $FFFFF.

3) Bit Instruction Addressing- This addressing type is used to access the memory area within $00000 - $0FFFF.- This is used to retrieve the value of a particular bit of a memory area

Page 14: WRES3315 Assignment 1_WEK090031

The following table summarizes the available addressing mode on both MCU:

FREESCALE MC9S08AW60 RENESAS R8C1) Inherent Addressing Mode (INH)2) Relative Addressing Mode (REL)3) Immediate Addressing Mode (IMM)4) Direct Addressing Mode (DIR)5) Extended Addressing Mode (EXT)6) Indexed Addressing Mode

General Instruction Addressing1) Immediate2) Register direct3) Absolute4) Address register indirect5) Address register relative6) SB relative7) FB relative8) Stack pointer relative

Special Instruction Addressing1) 20-bit absolute2) Address register relative with 20-bit

displacement3) 32-bit address register indirect4) 32-bit register direct5) Control register direct6) Program counter relative

Bit Instruction Addressing1) Register direct2) Absolute3) Address register indirect4) Address register relative5) SB relative6) FB relative7) FLG direct

Page 15: WRES3315 Assignment 1_WEK090031

MCU Instruction Set

An instruction set is a set of command that understood by the processor to perform out certain task. Different manufacturer may implement different kind of instruction set on their MCU.

FREESCALE MC9S08AW60Generally, the instruction set of MC9S08AW60 follow this format:

OPCODE $Destination$ $Source$

Instruction Form Description Operation1 ADC #opr8i

ADC opr8aADC opr16aADC oprx16,XADC oprx8,XADC ,XADC oprx16,SPADC oprx8,SP

Add with Carry A ← (A) + (M) + (C)

2 AND #opr8iAND opr8aAND opr16aAND oprx16,XAND oprx8,XAND ,XAND oprx16,SPAND oprx8,S

Logical AND A ← (A) & (M)

3 ASL opr8aASLAASLXASL oprx8,XASL ,XASL oprx8,SP

Arithmetic Shift Left(Same as LSL)

4 CLR opr8aCLRACLRXCLRHCLR oprx8,XCLR ,XCLR oprx8,SP

Clear M ← 0x00A ← 0x00X ← 0x00H ← 0x00M ← 0x00M ← 0x00M ← 0x00

Page 16: WRES3315 Assignment 1_WEK090031

5 DEC opr8aDECADECXDEC oprx8,XDEC ,XDEC oprx8,SP

Decrement M ← (M) – 0x01A ← (A) – 0x01X ← (X) – 0x01M ← (M) – 0x01M ← (M) – 0x01M ← (M) – 0x01

6 DIV Divide A ← (H:A)÷(X)H ← Remainder

7 INC opr8aINCAINCXINC oprx8,XINC ,XINC oprx8,SP

Increment M ← (M) + 0x01A ← (A) + 0x01X ← (X) + 0x01M ← (M) + 0x01M ← (M) + 0x01M ← (M) + 0x01

8 JMP opr8aJMP opr16aJMP oprx16,XJMP oprx8,XJMP ,X

Jump PC ← Jump Address

9 LDA #opr8iLDA opr8aLDA opr16aLDA oprx16,XLDA oprx8,XLDA ,XLDA oprx16,SPLDA oprx8,SP

Load Accumulator fromMemory

A ← (M)

10 MOV opr8a,opr8aMOV opr8a,X+MOV #opr8i,opr8aMOV ,X+,opr8a

Move (M)destination← (M)sourceH:X ← (H:X) + 0x0001 inIX+/DIR and DIR/IX+ Modes

Page 17: WRES3315 Assignment 1_WEK090031

RENESAS R8CThe instruction set of RENESAS R8C MCU is completely different from FREESCALE MCU.

Generally it follows the following format:

OPCODE.size (:format) source, destination

Where,

Size - Define the data sizes in which data is handled

The following data sizes may be specified:

.B Byte (8 bits) .W Word (16 bits) .L Long word (32 bits) Some instructions do not have a size specifier.

Format - Shows the instruction format.

If (: format) is omitted, the assembler chooses the optimum specifier. If (: format) is entered, its content is given priority. The following instruction formats may be specified:

:G Generic format :Q Quick format :S Short format :Z Zero format Some instructions do not have an instruction format specifier.

Instruction Form Description Operation1 ADC.size src,dest Addition with carry dest ← src + dest + C

2 AND.size (:format) src,dest Logical AND dest ← src & dest

3 BCLR (:format) dest Bit Clear dest ← 0

4 DEC.size dest Decrement dest ← dest – 1

5 DSUB.size src,dest Decimal Subtract dest ← dest – src

6 FSET dest Flag Register Set dest ← 1

7 JMP(.length) label Jump PC ← label

8 LDC src,dest Load dest ← src

9 MOV.size (:format) src,dest Move dest ← src

10 MUL.size src,dest Multiply dest ← dest x src

Page 18: WRES3315 Assignment 1_WEK090031

Reference:1. MC9S08AW60 Data Sheet -

http://www.freescale.com/files/microcontrollers/doc/data_sheet/MC9S08AW60.pdf

2. Renesas R8C Data Sheet - http://documentation.renesas.com/doc/products/mpumcu/rej09b0001_r8csm.pdf