TCC89x串口设置要点

//=====================================================================
//TITLE:
// TCC89x串口设置要点
//AUTHOR:
// norains
//DATE:
// Thursday 29-March-2011
//Environment:
// Visual Studio 2005
// Windows CE 6.0
// Telechips TCC8900
//=====================================================================

对于Telechips的TCC89x系列来说,串口资源不可谓不丰富,整整六组串口,应该能满足大多数的应用场合了。

如果运行的是Windows CE操作系统的话,除去作为调试的Debug口,那么还剩下五组可供应用程序使用。而这五组串口的使能,并不需要做太多的工作,只需要书写相应的注册表数值即可。只不过比较可惜的的是,Telechips原版的注册表,只使能COM1~COM3这三组,而COM4和COM5只能自己动手。不过这对于经验丰富的开发者来说,并不是一件很难的事情,完全可以依样画瓢。只不过,有下面几点需要注意。
  
1. COM_ChNum和COM_PortNum必须对应

COM_ChNum是串口的通道,COM_PortNum是对应的PIN脚,这两个数值都可以在注册表中进行设置。但这并不意味着,可以随意设置,而必须要按照如下的映射关系:

COM_ChNum

COM_PortNum

1

1

2

4

3

5

4

2

5

3

简单点来说,如果COM_ChNum为3的话,那么COM_PortNum就必须为5。为什么会有如此奇怪的关系呢?其实这是因为代码中规定的。打开Magellan/Src/LIB/SOC/UART/TCC89x/tca_serial.c文件,查看tca_serial_portinit函数,就可以发现代码中已经一一映射,如下图所示:
 TCC89x串口设置要点_第1张图片 


而注册表必须要和代码保持一致,所以COM_ChNum和COM_PortNum的关系也就定死了。

2. DMA不支持Channel4~Channel5

这个要点在Datasheet的800页有如下的说明:

翻译为中文,大致是:DMA发送和接收在UART的Channel0~3是可用的。但如果是Channel4和Channel5,因为无法使用硬件控制,所以无法DMA。如果一定要使用DMA传输方式,请确保使用的是Channel0~3。

因为在Telechips的默认注册表中,Channel0~3已经被调试口和COM1~COM3所使用了,剩下的COM4和COM5只能放弃DMA的方式。而具体到注册表,则是"USEDMATX"和"USEDMARX"这两个键值的数值必须为0。

最后,则是看看完整的串口设置信息列表,Telechips没有给出的COM4和COM5设置也一并在表格中列出:

序号

Channel

Port

Tx

Rx

注册表

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:on 0:off

"USEDMARX"=dword:0 ; 1:on 0: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:on 0:off

"USEDMARX"=dword:1 ; 1:on 0: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:on 0:off

"USEDMARX"=dword:1 ; 1:on 0: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:on 0:off

"USEDMARX"=dword:0 ; 1:on 0: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:on 0:off

"USEDMARX"=dword:0 ; 1:on 0: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

不支持

你可能感兴趣的:(串口)