新闻中心

EEPW首页 > 嵌入式系统 > 设计应用 > PowerPC简介及编程

PowerPC简介及编程

作者:时间:2017-06-04来源:网络收藏

PowerPC简介及编程

本文引用地址:http://www.eepw.com.cn/article/201706/348588.htm



一.PowerPC芯片

PowerPC是早期Motorola和IBM联合为Apple的MAC机开发的CPU芯片,商标权同时属于IBM和Motorola,并成为他们的主导成品.IBM主要的PowerPC产品有PowerPC604s(深蓝内部的CPU), PowerPC750,PowerPCG3(1.1GHz).Motorola主要有MC和MPC系列.尽管他们产品不一样,但都采用PowerPC的内核.这些产品大都用在嵌入式系统中.



二. Motorola的MPC860简介(摘录)

MPC860 PowerQUICC (Quad Integrated Communications Controller) 内部集成了微处理器和一些控制领域的常用外围组件, 特别适用于通信产品. 包括器件的适应性, 扩展能力和集成度等. MPC860 PowerQUICC集成了两个处理块. 一个处理块是嵌入的PowerPC核, 另一个是通信处理模块( CPM, Communications Processor Module), 通信处理模块支持四个串行通信控制器(SCC, Serial Communication Controller), 实际上它有八个串行通道: 四个SCC,两个串行管理控制器 (SMC, Serial Management Channels), 一个串行外围接口电路 ( SPI, Serial Peripheral Interface ) 和一个I2C( Inter-Integrated Circuit ) 接口. 由于CPM分担了嵌入式PowerPC核的外围工作任务, 这种双处理器体系结构功耗要低于传统的体系结构的处理器.

1.单出口, 嵌入式PowerPC核32比特版本(与PowerPC结构定义完全兼容)32x32位通用寄存器(GPRs, General Purpose Registers)

4K数据Cache和4K指令Cache, 分别带有一个MMU.

存储管理单元(MMU)32-输入翻译后备缓冲器 ( TLBs )

32位数据,地址线

2.存储控制器(八个存储体)

单线存储模块无逢接口,静态随即存取存储器(RAM), EPROM, FLASH MEMORY或DRAM等。

DRAM 控制器可编程支持绝大多数不同大小和速度的存储器

不同码组长度32K至256M

3.四个16位定时器或两个32位定时器.

4.系统集成单元 ( SIU, Sytstem Intergration Unit ) 主要包括:

软件看门狗

中断定时器

PowerPC 时基和实时时钟 (RTC, Real Time Clock )

复位控制器

JTAG 1149.1 测试口

5.中断系统包括7根外部中断请求线, 12个具有中断能力的管脚, 16个内部中断源. 中断优先级可编程

6.通信处理器模块(CPM)主要包括:

RISC 控制器

5 K字节双口RAM

16个串行DMA (SDMA) 通道

三个平行 I/O 寄存器

7.四个波特率独立的发生器, 可以连接到任意一个SCC和SMC, 并允许运行中改变. 支持自动波特率

8.四个串行通信控制器 (SCC) ,支持以太网, HDLC/SDLC, HDLC 总线(用以实现基于HDLC的局域网)、AppleTalk, 7号信令系统, UART、BISYNC, 比特流透明传输, 基于帧的透明传输 (CRC可选), 支持PPP (Point to Point Protocol)的异步HDLC等标准协议

9.两个串行管理控制器 (SMC), UART方式或透明传输, 含GCI(General Circuit Interface)控制器, 可以连到时分复用通道

10.一个串行外围接口电路( SPI ), 是MC68302 SCP的扩展, 支持主从模式, 支持同一总线上多主操作

11.一个I2C ( Inter-Integrated Circuit ) 接口,支持主从模式, 支持多主环境

12.单插座PCMCIA-异步终端适陪器(ATA)接口

单PCMCIA插座

八储存或有效输入/输出(I/O)窗口


 
三内存映射

MPC860的内存资源(如寄存器等)映射在一个连续的16K Block存储区内,可通过SPR中的Internal Map Memory Register(IMMR)进行解析

对 Memory Registers 操作的几种方式

Indirectly Access Registers Via Memory-----------------------通过指定的I/O寄存器(I/O port)对一个寄存器操作,

如PCI部分I/O操作示例如下:

PCI地址I/O寄存器: PCICFGADR 0xEEC00000
PCI数据I/O寄存器: PCICFGDATA 0xEEC00004

具体操作方法:将所要读写的寄存器地址写入PCI地址I/O寄存器PCICFGADR,从PCI数据I/O寄存器PCICFGDATA读出数据,这个数据就是写入地址的寄存器的数据.

RegAddr = 0x80000000 | ((offset|BusDevFunc) 0xFFFFFFFC);

RegAddr寄存器地址, 0x80000000 PCI core Address, offset寄存器偏移量

/*
* 写RegAddr到PCI I/O地址寄存器PCICFGADR
*/
sysPciOutLong(PCICFGADR, RegAddr);

/*
* 从PCI I/O数据寄存器读RegAddr数据data
*/
data = (unsigned int)sysPciInByte(PCICFGDATA | (offset 0x3));

Directly Access Registers Via Memory-------------------------直接对寄存器操作

Indirectly Access Registers Via DCR-----------------------------同上,

Directly Access Regesters Via DCR-------------------------------同上,

 

四,PowerPC内核定义

双处理器结构既提供了程序运行的通用处理器,又提供了用于通信用处的特殊通信处理器(CPM).

1.32位PowerPC结构特点

32个32位通用寄存器 ( GPRs )

寄存器支持用户级指令集 (不包括浮点指令),包括integer exception register (XER ),condition register(CR),link register(LR),counter register ( CTR )

时间加减及寄存器

管理级寄存器,与PowerPC定义兼容

Configuration-----Machine Status Register ( MSR )

Exception model-----Save/restore registers 0 and 1 (SRR0 and SRR1), DSI status register ( DSISR ), data address register ( DAR )

PowerPC 减量器

PowerPC 时基和 实时时钟(RTC)

 

2.地址映射
 

名称

内存物理地址

备注

SDRAM0x00000000~0x7FFFFFFF
PCI0x80000000~0xEF5FFFFF

Internal Peripherals

0xEF600000~0xEFFFFFFF
UART.....
..........

External Peripherals

0xF0000000~0xFF7FFFFF
NVRAM/RTC

0xF0000000~0xF0001FFF

(8K)下画线为片选
Keybord/Mouse0xF0100000~0xF0100001下画线为片选
FPGA_INT_ST..0xF0300000~0xF0300000下画线为片选
FPGA_INT_EN..0xF0300001~0xF0300001下画线为片选

Socket Flash

0xFFF80000~0xFFFFFFFF512K

SRAM

0xFFF00000~0xFFF7FFFF512K(可通过Swich与Socket Flash 切换)


 

3.中断优先级(Exception Priority)
 

PriorityException TypeCause
1Development portnonmaskable interrupt Signal from the development port
2System resetinterrupt IRQ0 assertion
3Instruction-related exceptionsInstruction processing
4Peripheral breakpoint request or development port maskable interruptBreakpoint signal from any peripheral
5External interrupt (masked if MSR[EE] = 0) Signal from the interrupt controller
6Decrementer interrupt(masked if MSR[EE] = 0)Decrementer request



 

 

4.中断向量表
 

中断向量表的起始地址取决于MSR[IP]的设置

MSR[IP]=0 Exceptions are vectored to the physical address 0x000n_nnnn

MSR[IP]=1 Exceptions are vectored to the physical address 0xFFFn_nnnn

OffsetExceptionDescription
0x00000Reserved 
0x00100System reset interrupt 
0x00200Machine check interrupt 
0x00300DSIA DSI exception is never generated by hardware, but software may branch to this location because of an data TLB error or miss exception.
0x00400ISIAn ISI exception is never generated by the hardware, but software may branch to this location because of an implementation-speciTc instruction TLB error exception.
0x00500External Interrupt 




这个表结合地址映射表可知系统复位的地址是 Socket Flash地址+系统复位偏移地址 = 0xFFF80000 + 0x0100 = 0xFFF80100,即系统通电后,跳到0xFFF80100的位置开始执行程序.

5.MPC860串口中断过程

MPC860集成了两个处理块,一个处理块是嵌入的PowerPC核,另一个是通信处理模块(CPM).通信处理模块有4个SCC和2个SMC,这六个通信口可以通过设置来支持多种协议和通信方式,也可设置为串口UART模式(是通过寄存器GSMR或SMCMR),功能和中断的定义和通常的串口定义基本是一致的在寄存器SCCM/SCCE的位14和位15定义了在何种情况下产生硬件中断.

根据MPC860中SCC UART Event Register(SCCE)的位14和位15定义,位14是数据发送中断标志位,位15是数据接收中断标志位,首先设置SCC UART Mask Register(SCCM)的位14和位15为1,使能接受和发送中断.

如果串口收到数据,则产生硬件RX中断,SCCE为15置1,通知系统有数据到达,有相应的中断例程ISR来取数据.

发送的情况下,数据FIFO为空,产生TX中断,告诉系统发送准备就绪,可以发送,ISR把数据放入FIFO中,发送中断位清零.当发送完毕后,FIFO再为空,再次产生中断,告诉系统发送准备就绪,继续发送.


6.MPC860片选信号的编程方法

在MPC860中,有片选信号CS0,CS1,...,CS7对他们的操作主要是要改变片选信号的电平.

一般来说片选信号的发生是对和这一片选线相关联的地址进行操作(读写)时片选信号改变。片选信号通常为低电平有效。比如MPC860的CS0是boot rom,硬件reset后,CPU会从boot rom的起始地址开始执行,CS0变为低电平。
所以只要对一个相应的地址操作,和这个地址芯片(bank)相连的CSx就会改变。
MPC860对CSx分配地址空间的在BRx中定义,BR0,BR1...BR7分别对应8个片选线CS0--CS7。


 

7.System Reset Interrupt (0x00100)

A system reset interrupt occurs when IRQ0 is asserted. When the exception is taken, processing begins at offset 0x00100. A hard or soft reset also causes program execution to begin fetching at 0x00100 after the associated reset actions.

Register Setting

SRR0: Set to the (Effective Address) EA of the next instruction of the interrupted process.

SRR1: Saves the machine status prior to exceptions and to restore status when an r f i instruction is executed.

1-4 ,-------0

10-15,--- 0

Others Loaded from MSR[16-31]. SRR1[30] is cleared only by loading a zero from MSR[RI].

MSR : IP No change ME No change LE Value of MSR[ILE] of the interrupted process. Others -----0

 

8.External Interrupt Exception (0x00500)

In the MPC860 the external interrupt is generated by the on-chip interrupt controller. It is software acknowledged and maskable by MSR[EE], which hardware clears automatically to disable external interrupts when any exception is taken.

Register Settings after an External Interrupt

Register Setting Description

SRR0 Set to the effective address of the instruction that the processor would have attempted to execute next if no interrupt conditions were present.

SRR1: 0, Loaded with equivalent bits from the MSR

1-4, Cleared; 5-9, Loaded with equivalent bits from the MSR; 10-15, Cleared; 16-31, Loaded with equivalent bits from the MSR

Note that depending on the implementation, reserved bits in the MSR may not be copied to SRR1.

MSR POW 0; ILE --; EE 0; PR 0; FP 0; ME --; SE 0; BE 0; IP --; IR 0; DR 0; RI 0; LE Set to value of ILE

 

9.Hard Reset ConTguration Word

The hard reset configuration word is sampled from the data bus. These bits determine the default values of the corresponding bits in the SIUMCR, IMMR, and MSR.

IIP:bit1: Initial interrupt prefix. Defines the initial value of the MSR[IP] which defines the interrupt table location. If

IIP is cleared (default), the MSR[IP] initial value is one; if it is set to one, the MSR[IP] initial value is zero.

ISB:bit 7-8, Initial internal space base select. Defines the initial value of the IMMR bits 0-15 and determines the

base address of the internal memory space.

00 0x00000000.

01 0x00F00000.

10 0xFF000000.

11 0xFFF00000.

 

 

 



评论


相关推荐

技术专区

关闭