Debug...210WinCE出现串口挂485发送的同时又自发自收的现象

时间:2022-12-27 03:35:19

以下是WinCE下的寄存器信息:

[UART] DMA init CH:1 
[UART2]********m_pSysconRegs*********
[UART2]m_pSysconRegs->CLK_SRC.CLK_SRC4:66667777
[UART2]m_pSysconRegs->CLK_DIV.CLK_DIV4:94490000
[UART2]m_pSysconRegs->CLK_DIV.CLK_DIV4:94490000
[UART2]m_pSysconRegs->CLK_SRC.CLK_SRC_MASK0:ffffffff
[UART2]: GPA1.GP_CON=0x00000022
[UART2]: GPA1.GP_CONPDN=0x00000000
[UART2]: GPA1.GP_DAT=0x0000000f
[UART2]: GPA1.GP_DRV_SR=0x0000005f
[UART2]: GPA1.GP_PAD=0xd2fe0038
[UART2]: GPA1.GP_PUD=0x00000051
[UART2]: GPA1.GP_PUDPDN=0x00000000
[UART] DMA init CH:2 


奶奶的,昨晚5点多开始,发现这一bug,一开始就应该相信自己的判断,领导根本不知道就在乱建议,硬件那边的领导过来测硬件还比较靠谱。我都本来就知道,只是这个挂了485的串口有问题...

好吧,现在又叫我这个先别弄,ok...你们说的算啊


2013年4月23日

花了一个早上,研究出Linux怎么打印出寄存器的值


#define GPA1CON 0xE0200020

#define DEVICE_NAME "tqmem"


/**
*初始化设备,配置对应的IO,以及注册设备
**/
static int __init dev_init(void)
{
int ret;

static void * GPA_BASE;

if(request_mem_region(GPA1CON,16,DEVICE_NAME)!=NULL) //16为从地址GPF开始的16个字节
{
GPA_BASE=ioremap(GPA1CON,16);

}

printk("GPA1_reg!\n");
printk("GPA1CON 0x%08x\n", readl(GPA_BASE));
printk("GPA1DAT 0x%08x\n", readl(GPA_BASE+4));
printk("GPA1PUD 0x%08x\n", readl(GPA_BASE+8));
printk("GPA1DRV 0x%08x\n", readl(GPA_BASE+12));
printk("GPA1CONPD 0x%08x\n", readl(GPA_BASE+16));
printk("GPA1PUDPDN 0x%08x\n", readl(GPA_BASE+20));
return ret;
}



Linux的

GPA1CON 0x00002222                                                              
GPA1DAT 0x0000000b                                                              
GPA1PUD 0x00000050                                                              
GPA1DRV 0x00000055                                                              
GPA1CONPD 0x00000000                                                            
GPA1PUDPDN 0x00000000                                                           
GPA1PAD 0x00000050


没猜错,WinCE还有继续设置的值

[UART] DMA init CH:1                                                            
[UART2]********m_pSysconRegs*********                                           
[UART2]m_pSysconRegs->CLK_SRC.CLK_SRC4:66667777                                 
[UART2]m_pSysconRegs->CLK_DIV.CLK_DIV4:94490000                                 
[UART2]m_pSysconRegs->CLK_DIV.CLK_DIV4:94490000                                 
[UART2]m_pSysconRegs->CLK_SRC.CLK_SRC_MASK0:ffffffff                            
[UART2]: GPA1.GP_CON=0x00000022                                                 
[UART2]: GPA1.GP_CONPDN=0x00000000                                              
[UART2]: GPA1.GP_DAT=0x0000000f                                                 
[UART2]: GPA1.GP_DRV_SR=0x0000005f                                              
[UART2]: GPA1.GP_PAD=0xd2fe0038                                                 
[UART2]: GPA1.GP_PUD=0x00000051                                                 
[UART2]: GPA1.GP_PUDPDN=0x00000000                                              
[UART] DMA init CH:2                                                            
 m_dwDevIndex == 2                                                              
UART3 Rx Tx Configured                                                          
[UART3]: GPA1.GP_CON=0x00002222                                                 
[UART3]: GPA1.GP_CONPDN=0x00000000                                              
[UART3]: GPA1.GP_DAT=0x0000000f                                                 
[UART3]: GPA1.GP_DRV_SR=0x000000ff                                              
[UART3]: GPA1.GP_PAD=0xd30a0038                                                 
[UART3]: GPA1.GP_PUD=0x00000011                                                 
[UART3]: GPA1.GP_PUDPDN=0x00000000                                              
[UART] DMA init CH:3 


WinCE的寄存器DRV PUD设置得跟Linux一样就解决问题了...