有几个问题需要咨询一下:
1 外部总线配置寄存器(R8_XBUS_CONFIG)的RB_XBUS_EN_32BIT为1,表示使用16位或32位的数据总线。哪么,使用16位数据总线时,D15~D0作为数据总线使用,D31~D16是否也会受到影响不能作为普通IO呢?
2 以下是CH563EVT的例程HOST.C中的函数,能否解释一下其中的循环目的是什么,会受到什么效果;而且,我觉得代码中的PRINT( "setup clk=1:\n" );及PRINT( "setup clk=2:\n" );之后的代码没有看出clk=1和clk=2的区别,能否解答一下?
void XbusTest( void )
{
UINT8 mFstDat, mTstDat;
UINT8 mHoldClk; /* hold clk */
UINT32 i, j;
PRINT( "Xbus Test\n" );
R32_PA_DIR = (1<<21)|( 1<<20 )|0x7FFF; /* 置地址、WR、RD信号输出 */
mFstDat = 0x55;
PRINT( "setup clk=1:\n" );
for( mHoldClk = 0; mHoldClk <= RB_XBUS_HOLD; mHoldClk ++ ){
R8_SAFE_ACCESS_SIG = 0x57; /* unlock step 1 */
R8_SAFE_ACCESS_SIG = 0xA8; /* unlock step 2 */
R8_XBUS_CONFIG = RB_XBUS_ENABLE | RB_XBUS_ADDR_OE; /* 外部总线使能 */
R8_XBUS_SETUP_HOLD = mHoldClk; /* 1 setup clocks */
R8_SAFE_ACCESS_SIG = 0x00; /* lock, to prevent unexpected writing */
j = 1024 * 32; /* 外部32K RAM */
pXbusPt = ( PUINT8V )0x00C00000; /* 外部总线基址 */
mTstDat = mFstDat;
PRINT( " mHoldClk=0x%x, FstDat=0x%x\n", ( UINT16 )mHoldClk, ( UINT16 )mFstDat );
PRINT( " write: " );
for( i = 0; i < j; i ++ ){
if( i < 16 ) PRINT( "%x ",( UINT16 )mTstDat ); /* 显示前16个数据 */
*pXbusPt = mTstDat;
pXbusPt ++;
mTstDat ^= 0xFF;
}
PRINT( "\n" );
PRINT( " read: " );
pXbusPt = ( PUINT8V )0x00C00000; /* 外部总线基址 */
mTstDat = mFstDat; /* 测试首数据 */
for( i = 0; i < j; i ++ ){
if( i < 16 ) PRINT( "%x ", ( UINT16 )*pXbusPt );
if( *pXbusPt != mTstDat ){
PRINT( " err: i=0x%lX, mTstDat=%x\n", ( UINT32 )i, ( UINT16 )mTstDat );
break;
}
pXbusPt ++;
mTstDat ^= 0xFF;
}
PRINT( "\n over\n" );
mFstDat ^= 0xFF;
}
PRINT( "setup clk=2:\n" );
for( mHoldClk = 0; mHoldClk <= RB_XBUS_HOLD; mHoldClk ++ ){
R8_SAFE_ACCESS_SIG = 0x57; /* unlock step 1 */
R8_SAFE_ACCESS_SIG = 0xA8; /* unlock step 2 */
R8_XBUS_CONFIG = RB_XBUS_ENABLE | RB_XBUS_ADDR_OE; /* 外部总线使能 */
R8_XBUS_SETUP_HOLD = mHoldClk; /* 1 setup clocks */
R8_SAFE_ACCESS_SIG = 0x00; /* lock, to prevent unexpected writing */
j = 1024 * 32; /* 外部32K RAM */
pXbusPt = ( PUINT8V )0x00C00000; /* 外部总线基址 */
mTstDat = mFstDat; /* 测试首数据 */
PRINT( " mHoldClk=0x%x, FstDat=0x%x\n", ( UINT16 )mHoldClk, ( UINT16 )mFstDat );
PRINT( " write: " );
for( i = 0; i < j; i ++ ){
if( i < 16 ) PRINT( "%x ",( UINT16 )mTstDat ); /* 显示前16个数据 */
*pXbusPt = mTstDat;
pXbusPt ++;
mTstDat ^= 0xFF;
}
PRINT( "\n" );
PRINT( " read: " );
pXbusPt = ( PUINT8V )0x00C00000; /* 外部总线基址 */
mTstDat = mFstDat; /* 测试首数据 */
for( i = 0; i < j; i ++ ){
if( i < 16 ) PRINT( "%x ", ( UINT16 )*pXbusPt );
if( *pXbusPt != mTstDat ){
PRINT( " err: i=0x%lX, mTstDat=%x\n", ( UINT32 )i, ( UINT16 )mTstDat );
break;
}
pXbusPt ++;
mTstDat ^= 0xFF;
}
PRINT( "\n over\n" );
mFstDat ^= 0xFF;
}
}