歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> 關於Linux >> uclinux-2008R1-RC8(bf561)到VDSP5的移植(41):PLL造成的困擾

uclinux-2008R1-RC8(bf561)到VDSP5的移植(41):PLL造成的困擾

日期:2017/3/3 16:43:30   编辑:關於Linux

出現一個很奇怪的問題:

DSP上電後直接在仿真器上運行uclinux內核,串口無法接收到正常輸出,僅有一兩個異常字符。但是用VDSP4.5運行原來寫的一個串口程序,可以正常輸出。

第一個郁悶的問題在於這個串口程序運行過一遍之後,再怎麼運行uclinux內核都沒有問題(除非斷電)。中斷後比較這兩個程序的UART_*相關的寄存器配置,完全相同。況且前後兩次運行uclinux,程序沒有任何變動,應該跟配置沒有關系才對。比較PLL的配置也是完全相同的(27M晶振,594M CCLK,99M SCLK)。

第二個郁悶的問題是,如果把uclinux內核編譯成ldr文件燒到flash上,也沒有任何問題。

究其原因,在head.s中有一段對PLL進行設置的代碼:

r0 = CONFIG_VCO_MULT & 63;  /* Load the VCO multiplier         */
r0 = r0 << 9;          /* Shift it over,                  */
r1 = CLKIN_HALF;        /* Do we need to divide CLKIN by 2?*/
r0 = r1 | r0;
r1 = PLL_BYPASS;        /* Bypass the PLL?                 */
r1 = r1 << 8;          /* Shift it over                   */
r0 = r1 | r0;          /* add them all together           */

p0.h = hi(PLL_CTL);
p0.l = lo(PLL_CTL);      /* Load the address                */
cli r2;             /* Disable interrupts              */
ssync;
w[p0] = r0.l;         /* Set the value                   */
ssync;
idle;             /* Wait for the PLL to stablize    */
sti r2;            /* Enable interrupts               */

程序運行到這裡時,PLL設置並沒有真正起作用,雖然寄存器的值改了。

在VDSP手冊上有一段說明:

Note: In order to program the PLL, both cores must be in an idled state. Alternatively, it is acceptable for core B to be in the “SRAM init” state that it enters after processor reset. For more information about this state, refer to "Booting Methods" on another page.

在VDSP環境下,B核實際是處於Fullon狀態,而設置PLL時要求B核沒有運行或者處於IDLE狀態。

原來的串口程序是兩個核都使用了的。這樣正確運行一次之後,即使後面的PLL設置沒有成功也沒什麼關系。

燒寫到flash之後,B核並沒有運行,因此PLL的設置也是成功的!

知道原因後就容易解決了:

在仿真器下運行時,為B核加上一條IDLE指令並先於A核運行就可以搞定這個問題。

哈哈!

Copyright © Linux教程網 All Rights Reserved