TCC89x串口設(shè)置要點(diǎn)
//=====================================================================
本文引用地址:http://www.ex-cimer.com/article/201609/304828.htm//TITLE:
// TCC89x串口設(shè)置要點(diǎn)
//AUTHOR:
// norains
//DATE:
// Thursday 29-March-2011
//Environment:
// Visual Studio 2005
// Windows CE 6.0
// Telechips TCC8900
//=====================================================================
對(duì)于Telechips的TCC89x系列來說,串口資源不可謂不豐富,整整六組串口,應(yīng)該能滿足大多數(shù)的應(yīng)用場(chǎng)合了。
如果運(yùn)行的是Windows CE操作系統(tǒng)的話,除去作為調(diào)試的Debug口,那么還剩下五組可供應(yīng)用程序使用。而這五組串口的使能,并不需要做太多的工作,只需要書寫相應(yīng)的注冊(cè)表數(shù)值即可。只不過比較可惜的的是,Telechips原版的注冊(cè)表,只使能COM1~COM3這三組,而COM4和COM5只能自己動(dòng)手。不過這對(duì)于經(jīng)驗(yàn)豐富的開發(fā)者來說,并不是一件很難的事情,完全可以依樣畫瓢。只不過,有下面幾點(diǎn)需要注意。
1. COM_ChNum和COM_PortNum必須對(duì)應(yīng)
COM_ChNum是串口的通道,COM_PortNum是對(duì)應(yīng)的PIN腳,這兩個(gè)數(shù)值都可以在注冊(cè)表中進(jìn)行設(shè)置。但這并不意味著,可以隨意設(shè)置,而必須要按照如下的映射關(guān)系:
COM_ChNum | COM_PortNum |
1 | 1 |
2 | 4 |
3 | 5 |
4 | 2 |
5 | 3 |
簡(jiǎn)單點(diǎn)來說,如果COM_ChNum為3的話,那么COM_PortNum就必須為5。為什么會(huì)有如此奇怪的關(guān)系呢?其實(shí)這是因?yàn)榇a中規(guī)定的。打開Magellan/Src/LIB/SOC/UART/TCC89x/tca_serial.c文件,查看tca_serial_portinit函數(shù),就可以發(fā)現(xiàn)代碼中已經(jīng)一一映射,如下圖所示:
而注冊(cè)表必須要和代碼保持一致,所以COM_ChNum和COM_PortNum的關(guān)系也就定死了。
2. DMA不支持Channel4~Channel5
這個(gè)要點(diǎn)在Datasheet的800頁有如下的說明:
翻譯為中文,大致是:DMA發(fā)送和接收在UART的Channel0~3是可用的。但如果是Channel4和Channel5,因?yàn)闊o法使用硬件控制,所以無法DMA。如果一定要使用DMA傳輸方式,請(qǐng)確保使用的是Channel0~3。
因?yàn)樵赥elechips的默認(rèn)注冊(cè)表中,Channel0~3已經(jīng)被調(diào)試口和COM1~COM3所使用了,剩下的COM4和COM5只能放棄DMA的方式。而具體到注冊(cè)表,則是USEDMATX和USEDMARX這兩個(gè)鍵值的數(shù)值必須為0。
最后,則是看看完整的串口設(shè)置信息列表,Telechips沒有給出的COM4和COM5設(shè)置也一并在表格中列出:
序號(hào) | Channel | Port | Tx | Rx | 注冊(cè)表 | DMA |
Debug | 0 | 0 | GPIO E[0] | GPIO E[1] | 無 | 支持 |
COM1 | 3 | 5 | GPIO D[17] | GPIO D[18] | [HKEY_LOCAL_MACHINE/Drivers/BuiltIn/Serial1] DeviceArrayIndex=dword:0 COM_ChNum=dword:3 COM_PortNum=dword:5 MemBase=dword:B100C000 irq=dword:2F MemLen=dword:2C InterruptBitsShift=dword:0 ; UART 0 Interrupt Sub Register shift bit. ISTTimeouts=dword:200; every 512 ticks checking Modem status. Prefix=COM Index=dword:1 Dll=tcc_serial.dll Order=dword:1 Priority256=dword:e0 Port=COM1: DeviceType=dword:0 FriendlyName=Serial Cable on COM1: Tsp=unimodem.dll IsrDll=tcc_giisr.dll IsrHandler=ISRHandler DMAIsrHandler=DMAUARTISRHandler USEDMATX=dword:1; 1:on0:off USEDMARX=dword:0; 1:on0:off IClass={CC5195AC-BA49-48a0-BE17-DF6D1B0173DD} DevConfig=hex: 10,00, 00,00, 05,00,00,00, 10,01,00,00, 00,4B,00,00, 00,00, 08, 00, 00, 00,00,00,00 | 支持 |
COM2 | 1 | 1 | GPIO E[4] | GPIO E[5] | [HKEY_LOCAL_MACHINE/Drivers/BuiltIn/Serial2] DeviceArrayIndex=dword:1 COM_ChNum=dword:1 COM_PortNum=dword:1 MemBase=dword:B1008000 irq=dword:2F MemLen=dword:2C InterruptBitsShift=dword:0 ; UART Interrupt Sub Register shift bit. ISTTimeouts=dword:200; every 512 ticks checking Modem status. Prefix=COM Index=dword:2 Dll=tcc_serial.dll Order=dword:1 Priority256=dword:e0 Port=COM2: DeviceType=dword:0 FriendlyName=Serial Cable on COM2: Tsp=unimodem.dll IsrDll=tcc_giisr.dll IsrHandler=ISRHandler DMAIsrHandler=DMAUARTISRHandler USEDMATX=dword:1; 1:on0:off USEDMARX=dword:1; 1:on0:off IClass={CC5195AC-BA49-48a0-BE17-DF6D1B0173DD} DevConfig=hex: 10,00, 00,00, 05,00,00,00, 10,01,00,00, 00,4B,00,00, 00,00, 08, 00, 00, 00,00,00,00 | 支持 |
COM3 | 2 | 4 | GPIO D[13] | GPIO D[14] | [HKEY_LOCAL_MACHINE/Drivers/BuiltIn/Serial3] DeviceArrayIndex=dword:2 COM_ChNum=dword:2 COM_PortNum=dword:4 MemBase=dword:B1004000 irq=dword:2F MemLen=dword:2C InterruptBitsShift=dword:0 ; UART Interrupt Sub Register shift bit. ISTTimeouts=dword:200; every 512 ticks checking Modem status. Prefix=COM Index=dword:3 Dll=tcc_serial.dll Order=dword:1 Priority256=dword:e0 Port=COM3: DeviceType=dword:0 FriendlyName=Serial Cable on COM3: Tsp=unimodem.dll IsrDll=tcc_giisr.dll IsrHandler=ISRHandler DMAIsrHandler=DMAUARTISRHandler USEDMATX=dword:1; 1:on0:off USEDMARX=dword:1; 1:on0:off IClass={CC5195AC-BA49-48a0-BE17-DF6D1B0173DD} DevConfig=hex: 10,00, 00,00, 05,00,00,00, 10,01,00,00, 00,4B,00,00, 00,00, 08, 00, 00, 00,00,00,00 | 支持 |
COM4 | 4 | 2 | GPIO E[8] | GPIO E[9] | [HKEY_LOCAL_MACHINE/Drivers/BuiltIn/Serial4] DeviceArrayIndex=dword:3 COM_ChNum=dword:4 COM_PortNum=dword:2 MemBase=dword:B1000000 irq=dword:2F MemLen=dword:2C InterruptBitsShift=dword:0 ; UART Interrupt Sub Register shift bit. ISTTimeouts=dword:200; every 512 ticks checking Modem status. Prefix=COM Index=dword:4 Dll=tcc_serial.dll Order=dword:1 Priority256=dword:e0 Port=COM4: DeviceType=dword:0 FriendlyName=Serial Cable on COM4: Tsp=unimodem.dll IsrDll=tcc_giisr.dll IsrHandler=ISRHandler DMAIsrHandler=DMAUARTISRHandler USEDMATX=dword:0; 1:on0:off USEDMARX=dword:0; 1:on0:off IClass={CC5195AC-BA49-48a0-BE17-DF6D1B0173DD} DevConfig=hex: 10,00, 00,00, 05,00,00,00, 10,01,00,00, 00,4B,00,00, 00,00, 08, 00, 00, 00,00,00,00 | 不支持 |
COM5 | 5 | 3 | GPIO E[10] | GPIO E[11] | [HKEY_LOCAL_MACHINE/Drivers/BuiltIn/Serial5] DeviceArrayIndex=dword:4 COM_ChNum=dword:5 COM_PortNum=dword:3 MemBase=dword:B0FFC000 irq=dword:2F MemLen=dword:2C InterruptBitsShift=dword:0 ; UART Interrupt Sub Register shift bit. ISTTimeouts=dword:200; every 512 ticks checking Modem status. Prefix=COM Index=dword:5 Dll=tcc_serial.dll Order=dword:1 Priority256=dword:e0 Port=COM5: DeviceType=dword:0 FriendlyName=Serial Cable on COM5: Tsp=unimodem.dll IsrDll=tcc_giisr.dll IsrHandler=ISRHandler DMAIsrHandler=DMAUARTISRHandler USEDMATX=dword:0; 1:on0:off USEDMARX=dword:0; 1:on0:off IClass={CC5195AC-BA49-48a0-BE17-DF6D1B0173DD} DevConfig=hex: 10,00, 00,00, 05,00,00,00, 10,01,00,00, 00,4B,00,00, 00,00, 08, 00, 00, 00,00,00,00 | 不支持 |
評(píng)論