? ?:?C321? - PowerPoint PPT Presentation

About This Presentation
Title:

? ?:?C321?

Description:

C321 Phone 13819195905 Email Chenpeng_at_zjut.edu.cn 3 ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 48
Provided by: zj77
Category:
Tags: c321

less

Transcript and Presenter's Notes

Title: ? ?:?C321?


1
DSP?????I
????? ? ??C321? Phone13819195905 EmailChenp
eng_at_zjut.edu.cn
2
????????
1?DSP????--2?
A. DSP (Digital Signal Processing)???????(??),??
????????????,?????????????????????????????????,???
????????????
B. DSP (Digital Signal Processor)????????????????
???????,?????????????????????????????
3
????????(?)
2?DSP??????--?????????????
3?DSP???????? --?????????( ??1)????2)?????3)???
?)
4?DSP????? -- TI?DSP( C2000,C5000,C6000,OMAP,
DaVinci)
4
????????(?)
5???DSP????????--?????????????????????????
6?DSP???????? --
????????????????????DSP?????\FPGA???????????
5
????????(?)
7?TMS320F281?TMS320C281???
?C281X????,F281X???DSP???Flash????
F281X??,??????????,???????????????
8?F2810?F2811?F2812?????
F2812?F2810?F2811?????????? F2812?F2811?Flash?128K
,F2810?Flash??64K? F2812??????176,
?F2810?F2811??????128?
6
????
  • ?2????????
  1. ???????
  2. ???????
  3. CPU???
  4. ??I/O
  5. ????????(PIE)
  6. ???????

7
1 ???????
TMS320F281?????PLL?????,??????????????
???(OSCCLK)???????
a)??????X1/XCLKIN?X2???????? b)??????????????X1
/XCLKIN??,X2??,???????????
8
1 ???????(?)
????(CLKIN)??? 1)?????,??XPLLDIS0?,CPU??????????
???????????? 2)?????,??XPLLDIS1?,??????PLL(Phase
Locked Loop)???????CPU?????
(1)
???????????
(2)
(3)
8
9
1. ???????(?)
?? ???? SYSCLKOUT
??PLL ???????/XPLLDIS????,???PLL?????????X1/XCLKIN?????????CPU??? XCLKIN
??PLL ??????????PLL?????,?PLL????????,????X1/XCLKIN?????????2?????CPU??? XCLKIN/2
??PLL ???PLLCCR??????????n????PLL?/2???PLL?????????CPU??? (XCLKINn)/2
30MHz
15MHz
15-150MHz
????????(PLLCR--0x00007021)
10
1 ???????(?)
????????(PLLCR--0x00007021)
????????PLL??,OSCCLK30MHz,??5???
11
1. ???????(?)
// This function initializes the PLLCR
register. void InitPll(unsigned int val)
volatile unsigned int i EALLOW
SysCtrlRegs.PLLCR.bit.DIV val EDIS
DisableDog() // Wait PLL lock
cycles. for(i 0 ilt ( (131072/2)/12 )
i)
???PLLCR?????
Val 010
????????????
????PLL??????
?????????????0???????RAM?????????FLASH???????????
,????????????
12
1 ???????(?)
volatile unsigned int i
??????????????,???????????/???????C?????????/???,?
??????volatile ??????,???????????????,????DSP?
???????,???????C???????????volatile
???????????????,???????????????
13
1 ???????(?)
?????volatile ??????????,?????????????????,??????
??????????????????????????
volatile int i10 int a i ...
//????,?????????,?i????? int b i
??volatile,????????i??????????????i?????,????????
?????b????????i????????,??i???????????????????????
,???volatile???????????????
14
1 ???????(?)
sum
1.8V
3.3V
?????
??DSP??????????,?????????
15
1 ???????(?)
????????? (PCLKCR)????????????(?CAN??)
  • ????????? (HISPCP)
  • ????(??)EVA,EVB,ADC
  • HSPCLKSYSCLK/(114)
  • ????????SYSCLK/2

75MHz
  • ????????? (LOSPCP)
  • ????(??)SCIA,SCIB,SPI,McBSp
  • LSPCLKSYSCLK/(114)
  • ????????SYSCLK/4

37.5MHz
16
????????P19 ?2.4?2.5?2.6
void InitPeripheralClocks(void) EALLOW //
HISPCP/LOSPCP will be set to default values
SysCtrlRegs.HISPCP.all 0x0001 //
HSPCLKSYSCLK/2 SysCtrlRegs.LOSPCP.all
0x0002 // LSPCLKSYSCLK/4 // Peripheral
clock enables set for the selected peripherals.
SysCtrlRegs.PCLKCR.bit.EVAENCLK1
SysCtrlRegs.PCLKCR.bit.EVBENCLK1
SysCtrlRegs.PCLKCR.bit.SCIAENCLK1
SysCtrlRegs.PCLKCR.bit.SCIBENCLK1
SysCtrlRegs.PCLKCR.bit.MCBSPENCLK1
SysCtrlRegs.PCLKCR.bit.SPIENCLK1
SysCtrlRegs.PCLKCR.bit.ECANENCLK1
SysCtrlRegs.PCLKCR.bit.ADCENCLK1 EDIS
// This function initializes the clocks to the
peripheral modules.
1???????,????????????? 2??????????,??????????????
17
2 ???????
?????
18
2 ???????(?)
????? 30MHz/512/64/2563.58Hz,?????????279ms
????????WDCR
  • ??????????WDFLAG
  • ?1--?????(WDRST)0--????
  • ?1--?WDFLAG??0--WDFLAG????
  • ?1?WDDIS,????????0????????
  • WDCHK(53)???101,??????DSP???
  • WDPS(20)?????????(2???)
  • WDCLKOSCCLK/512/(164)?

19
2 ???????(?)
// This function disables the watchdog
timer. void DisableDog(void) EALLOW
SysCtrlRegs.WDCR 0x0068 //WDDIS1, WDCHK101,
EDIS //
WDPS000 (WDCLKOSCCLK/512)
// This function enables the watchdog
timer. void EnableDog(void) EALLOW
SysCtrlRegs.WDCR 0x0028 //WDDIS0, WDCHK101,
EDIS //
WDPS000 (WDCLKOSCCLK/512)
20
2 ???????(?)
??????????SCSR
  • WDINTS????????,??WDINT????
  • WDENINT
  • 1--???????(WDRST)???, ?????????(WDINT)
  • 0--???????(WDRST)???, ?????????(WDINT)
  • WDOVERRIDE
  • 1--????WDCR????????WDDIS0--????WDDIS
  • ???????????????????,??????????

21
2 ???????(?)
????????WDKEY
  • ???0x550xAA?WDKEY??WDCNTR??
  • ??????????????
  • ????????WDCR??????

22
2 ???????(?)
// This function resets the watchdog timer. void
KickDog(void) EALLOW SysCtrlRegs.WDKEY
0x0055 SysCtrlRegs.WDKEY 0x00AA
EDIS
???????????,????????????KickDog??,????????????????
????
23
2 ???????(?)
????????WDCNTR
  • WDCNTR??????????????(0-0xFF)
  • ???????,??????????DSP
  • ???WDKEY??????( 0x550xAA ),????????

24
2 ???????(?)
???????
// -This function initializes the System Control
registers to a known state. void
InitSysCtrl(void) // Disable the watchdog
DisableDog() // Initialize the
PLLCR to 0xA InitPll(0xA) // Initialize
the peripheral clocks InitPeripheralClocks()

1???????? 2???PLLCR???,??SYSCLKOUT???
3?????/???????????? 4?????????
??????????????,??????????????? PLLCR????10,?CPU???
???30MHz5?
25
3 CPU???
  • F281????3?32?CPU???(TIMER0/1/2)
  • TIMER0??????????,TIMER1/2???DSP BIOS??(????DSP
    BIOS,????????)?
  • ??????4????
  • 1)?????(TIMHTIM)32?
  • 2)?????(PRDHPRD)32?
  • 3)??????(TPR) 32?(??????PSC?????TDDR)
  • 4)?????(TCR)16?

25
26
3 CPU???(?)
TIMERx?????(TCR)
  • TIF-Timer Interrupt Flag
  • TIE-Timer Interrupt Enable
  • TRB-Timer Reload Bit
  • TSS-Timer Stop/Start Bit

???P27 ?2.17
27
3 CPU???(?)
???????? 1)?32??????(TIMHTIM)???????(PRDHP
RD)?????? 2)???????SYSCLKOUT??????(16?32?)
3)????????0?,??????????????????,?????????(TI
NT0)?
CPU???????
28
3 CPU???(?)
???????????????DSP????Freq(MHz)??????Period(µs)
?????????????????????
void ConfigCpuTimer(struct CPUTIMER_VARS Timer,
float Freq, float Period) unsigned long
temp Timer-gtCPUFreqInMHz Freq //
Initialize timer period Timer-gtPeriodInUSec
Period temp (long) (Freq Period)
// 150MHz100us15000 Timer-gtRegsAddr-gtPRD.all
temp Timer-gtRegsAddr-gtTPR.all 0 // Set
pre-scale counter to divide by 1
Timer-gtRegsAddr-gtTPRH.all 0 // Initialize
timer control register Timer-gtRegsAddr-gtTCR.bit.
TSS 1 // 1 Stop timer, 0 Start Timer
Timer-gtRegsAddr-gtTCR.bit.TRB 1 // 1
reload timer Timer-gtRegsAddr-gtTCR.bit.SOFT
1 Timer-gtRegsAddr-gtTCR.bit.FREE 1 //
Timer Free Run Timer-gtRegsAddr-gtTCR.bit.TIE 1
// 1 Enable Timer Interrupt
29
4 ??I/O
  • F281????56????????,
  • ??GPxMUX??????????????I/O??
  • ???????I/O??,?????????(GPxDIR)?????????????????
    (GPxQUAL)????????(QUAL PRD),?????????????

30
4 ??I/O(?)
  • GPxMUX???
  • GPxMUX.bit0- ???I/O??1-???????
  • GPxDIR???
  • GPxDIR.bit0- ???????1-???????
  • GPxDAT???
  • GPxDAT.bit?????????,????????
  • GPxSET???
  • GPxSET.bit 1- ???????????
  • GPxCLEAR???
  • GPxCLEAR.bit 1-???????????
  • GPxTOGGLE???
  • GPxTOGGLE.bit1-????????????

31
void InitGpio(void) // This function
initializes the Gpio to a known state.
EALLOW // ?? GPIO A??,
AL(70)???-AH(158)??? GpioMuxRegs.GPAMUX.al
l0x0000 // sets GPIO Muxs as I/Os
GpioMuxRegs.GPADIR.all0xFF00 // upper byte as
output/low byte as input GpioMuxRegs.GPAQUAL.
all0x0000 // Input qualifier disabled
GpioDataRegs.GPADAT.all0xAA00 // Toggle I/Os
using DATA registers GpioDataRegs.GPASET.all
0xAA00 // Toggle I/Os using SET/CLEAR registers
GpioDataRegs.GPACLEAR.all0x5500
GpioDataRegs.GPATOGGLE.all0xFF00 // Toggle I/Os
using TOGGLE registers // Set GPIO B port
pins, configured as EVB signals
GpioMuxRegs.GPBMUX.all0xFFFF // Configure
peripherals signals on the pins
GpioMuxRegs.GPBQUAL.all0x0000 // Input
qualifier0 (disabled) EDIS
32
5 PIE????
  • F281???17?CPU???,??1???????NMI?16??????(INT1INT
    14,RTOSINT?DLOGINT)
  • ????????(PIE)????????1??????PIE????96????,??8????
    ???,????????,???12?????(INT1INT12)
  • PIE ?????????????INT1-INT12,??8??????????????INTx
    .1-INTx.8
  • ?????????????????RAM?,????????????????????????
  • ??????25616??SRAM??,??????????2?16??????(??P39
    ?2.23)?

33
  • DSP281X???
  • 45?PIE??
  • 16?CPU??
  • ??NMI??
  • 3??????

34
PIEIFRx.y
IERx
INTM
PIEIERx.y
PIEACKx
ISR
35
5 PIE????
PIE???????(PIECTRL)
PIEVECT(151)???????????????
ENPIE1?????????PIE????? ENPIE0???CPU???
??P42 ?2.25
36
5 PIE????
PIE???????(PIEACK)
INT12
INT1
  • PIEACK(110)
  • ????????????,?PIEACK?????1???PIE???????????CPU???
    ??
  • ?PIEACK?????????????????

37
5 PIE????(?)
PIE???????(PIEIFRx)
  • ??????,????1?DSP??????,?????????
  • ?????????????????

38
5 PIE????(?)
PIE???????(PIEIERx)
?1??????????0??????
39
5 PIE????(?)
CPU???????(IFR)
  • 0--?????
  • 1--?????????
  • ???????????????

40
5 PIE????(?)
CPU???????(IER)
  • 0--????
  • 1--????
  • ???IER?????
  • ????OR IER ???????AND IER??????

41
6 ???????
  • ?? CPU???0??????
  • ????LED???????(0/1)

??????? 1)???????????? 2)?????????????--InitPieCt
rl() 3)CPU???????????--main() 4)?????????????--ma
in() 5)??????--ISRTimer0()
41
42
6 ???????(?)
??1????????
const struct PIE_VECT_TABLE PieVectTableInit
PDPINTA_ISR, // EV-A
PDPINTB_ISR, // EV-B rsvd_ISR,
XINT1_ISR, XINT2_ISR,
ADCINT_ISR, // ADC TINT0_ISR,
// Timer 0 WAKEINT_ISR, // WD
??2?????????????,?CPU???0?
volatile unsigned long TINT0(volatile unsigned
long )0x000D4C
43
define EINT asm(" clrc INTM") define DINT
asm(" setc INTM")
void InitPieCtrl(void) DINT
// Disable Interrupts
at the CPU level PieCtrlRegs.PIECRTL.bit.ENPIE
0 // Disable the PIE PieCtrlRegs.PIEIER1.
all 0 // Clear all PIEIER registers
PieCtrlRegs.PIEIER2.all 0
PieCtrlRegs.PIEIER12.all 0
PieCtrlRegs.PIEIFR1.all 0 // Clear
all PIEIFR registers. PieCtrlRegs.PIEIFR2.all
0 PieCtrlRegs.PIEIFR12.all 0
PieCtrlRegs.PIECRTL.bit.ENPIE 1 // Enable the
PIE PieCtrlRegs.PIEACK.all 0xFFFF //
Enables PIE to drive a pulse into the CPU
44
6 ???????(?)
void InitPieVectTable(void) // Initializes the
PIE vector table to a known state. int16 i Ui
nt32 Source (void ) PieVectTableInit Uint32
Dest (void ) 0x000D00 EALLOW for(i0 i
lt 128 i) Dest Source EDIS PieCtrl
Regs.PIECRTL.bit.ENPIE 1 // Enable the PIE
Vector Table
45
void main(void) InitSysCtrl()
//??????? DINT //??? IER
0x0000 IFR 0x0000 InitPieCtrl()
//???PIE InitPieVectTable()
//???PIE?????,?????1 InitPeripherals()
//?????,???????? EALLOW PieVectTable.TINT0
ISRTimer0 //??1 TINT0 (unsigned
long)ISRTimer0 //??2 EDIS ConfigCpuTimer(C
puTimer0, 150, 1000000) //??CPU???0 CpuTimer0Reg
s.TCR.bit.TSS 0 //??CPU???0
PieCtrl.PIEIER1.all 0x40
//??CPU???0?? IER 0x0001 EINT
// Enable Global
interrupt INTM for()
46
6 ???????(?)
define LED1_ON GpioDataRegs.GPFDAT.bit.GPIOF110
define LED1_OFF GpioDataRegs.GPFDAT.bit.GPIOF11
1 // PIE Group 1 - MUXed into CPU INT1 interrupt
void ISRTimer0(void) PieCtrl.PIEACK.all
0x0001 if(Led_Flag 1)
LED1_ON Led_Flag 0 else
LED1_OFF Led_Flag 1
47
?????????3? ????????
??2-2,2-3
?????!
Write a Comment
User Comments (0)
About PowerShow.com