在学习《领航者ZYNQ之嵌入式SDK开发指南_v2.0》的第十五章双核AMP实验时,软中断出现问题,对CPU0的代码稍加修改,将scanf输入freq_gear修改为freq_gear自动变化,其余代码均未修改。然后软中断没有触发,最后在XScuGic_SoftwareIntr(&Intc,SOFT_INTR_ID_TO_CPU1,CPU1_ID);前面加了延时函数,软件中断又可以触发,这是为什么呢? 修改前CPU0主函数代码: //CPU0 main函数int main(){ //S=b1 TEX=b100 AP=b11, Domain=b1111, C=b0, B=b0 Xil_SetTlbAttributes(SHARE_BASE,0x14de2); //禁用OCM的Cache属性 //启动CPU1 start_cpu1(); //CPU0中断初始化 cpu0_intr_init(&Intc); while(1){ if(rec_freq_flag == 0){ xil_printf("This is CPU0,Please input the numbers 1~5 to change breath led frequency\r\n"); scanf("%d",&freq_gear); if(freq_gear >= 1 && freq_gear <=5){ xil_printf("You input number is %d\r\n",freq_gear); //向共享的地址中写入输入的数据 Xil_Out8(SHARE_BASE,freq_gear); //给CPU1触发中断 XScuGic_SoftwareIntr(&Intc,SOFT_INTR_ID_TO_CPU1,CPU1_ID); rec_freq_flag = 1; }else{ xil_printf("Error,The number range is 1~5\r\n"); xil_printf("\r\n"); } } } return 0 ;}
修改后CPU0主函数代码:
int main()
{ //S=b1 TEX=b100 AP=b11, Domain=b1111, C=b0, B=b0 Xil_SetTlbAttributes(SHARE_BASE,0x14de2); //禁用OCM的Cache属性 //启动CPU1 start_cpu1(); //CPU0中断初始化 cpu0_intr_init(&Intc); freq_gear = 1; while(1){ if(rec_freq_flag == 0){ // xil_printf("This is CPU0,Please input the numbers 1~5 to change breath led frequency\r\n"); if(freq_gear >= 1 && freq_gear <=5){ xil_printf("You input number is %d\r\n",freq_gear); //向共享的地址中写入输入的数据 Xil_Out8(SHARE_BASE,freq_gear); //给CPU1触发中断 XScuGic_SoftwareIntr(&Intc,SOFT_INTR_ID_TO_CPU1,CPU1_ID); rec_freq_flag = 1; freq_gear ++; if(freq_gear>5){ freq_gear = 1; } }else{ xil_printf("Error,The number range is 1~5\r\n"); xil_printf("\r\n"); } } } return 0 ;}
|