1.設置.cmd檔,根據所需的大小調整 RUN,這邊選用 RMALS4
/* CLA specific sections */
Cla1Prog : LOAD = FLASHD,
RUN = RAMLS4,
LOAD_START(_Cla1funcsLoadStart),
LOAD_END(_Cla1funcsLoadEnd),
RUN_START(_Cla1funcsRunStart),
LOAD_SIZE(_Cla1funcsLoadSize),
PAGE = 0, ALIGN(4)
2.main.c置入初始化記憶體,這邊程序空間選用LS4 記憶體分配用 LS3
void CLA_configClaMemory(void)
{
extern uint32_t Cla1funcsRunStart, Cla1funcsLoadStart, Cla1funcsLoadSize;
EALLOW;
#ifdef _FLASH
// Copy over code from FLASH to RAM
memcpy((uint32_t *) &Cla1funcsRunStart, (uint32_t *) &Cla1funcsLoadStart,
(uint32_t) &Cla1funcsLoadSize);
#endif //_FLASH
// Initialize and wait for CLA1ToCPUMsgRAM
MemCfgRegs.MSGxINIT.bit.INIT_CLA1TOCPU = 1;
while (MemCfgRegs.MSGxINITDONE.bit.INITDONE_CLA1TOCPU != 1)
{
};
// Initialize and wait for CPUToCLA1MsgRAM
MemCfgRegs.MSGxINIT.bit.INIT_CPUTOCLA1 = 1;
while (MemCfgRegs.MSGxINITDONE.bit.INITDONE_CPUTOCLA1 != 1)
{
};
// Select LS5RAM to be the programming space for the CLA
// First configure the CLA to be the master for LS5 and then
// set the space to be a program block
MemCfgRegs.LSxMSEL.bit.MSEL_LS4 = 1;
MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS4 = 1;
MemCfgRegs.LSxMSEL.bit.MSEL_LS3 = 1;
MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS3 = 0;
EDIS;
}
3.初始化 CLA 並根據所需要的中斷配置,這邊選用Timer0中斷呼叫cla1Isr1
void CLA_initCpu1Cla1(void)
{
// Compute all CLA task vectors
// On Type-1 CLAs the MVECT registers accept full 16-bit task addresses as
// opposed to offsets used on older Type-0 CLAs
EALLOW;
Cla1Regs.MVECT1 = (uint16_t) (&Cla1Task1);
Cla1Regs.MVECT2 = (uint16_t) (&Cla1Task2);
Cla1Regs.MVECT3 = (uint16_t) (&Cla1Task3);
/*
Cla1Regs.MVECT4 = (uint16_t)(&Cla1Task4);
Cla1Regs.MVECT5 = (uint16_t)(&Cla1Task5);
Cla1Regs.MVECT6 = (uint16_t)(&Cla1Task6);
Cla1Regs.MVECT7 = (uint16_t)(&Cla1Task7);
Cla1Regs.MVECT8 = (uint16_t)(&Cla1Task8);*/
// Enable the IACK instruction to start a task on CLA in software
// for all 8 CLA tasks. Also, globally enable all 8 tasks (or a
// subset of tasks) by writing to their respective bits in the
// MIER register
Cla1Regs.MCTL.bit.IACKE = 1;
Cla1Regs.MIER.all = 0x00FF;
// Configure the vectors for the end-of-task interrupt for all
// 8 tasks
PieVectTable.CLA1_1_INT = &cla1Isr1;
PieVectTable.CLA1_2_INT = &cla1Isr2;
PieVectTable.CLA1_3_INT = &cla1Isr3;
/*
PieVectTable.CLA1_4_INT = &cla1Isr4;
PieVectTable.CLA1_5_INT = &cla1Isr5;
PieVectTable.CLA1_6_INT = &cla1Isr6;
PieVectTable.CLA1_7_INT = &cla1Isr7;
PieVectTable.CLA1_8_INT = &cla1Isr8;*/
// Set the TINT1 as the trigger for task 1
DmaClaSrcSelRegs.CLA1TASKSRCSEL1.bit.TASK1 = 68;
// Enable CLA interrupts at the group and subgroup levels
PieCtrlRegs.PIEIER11.all = 0xFFFF;
IER |= (M_INT11);
EDIS;
}
4.新增 SubFunction.cla
5.放置所需要的程序到SubFunction.cla 即可使用,但要注意大小不要超過RMALS4 不然會報錯
Susan Yang:
谢谢您的分享!