error: #136: struct "" has no fieild "USART_Parity" USART_InitStructure.USART_Parity = USART_Parity_No; error: #136: struct "" has no fieild "USART_Clock" USART_InitStructure....... error: #136: struct "" has no fieild "USART_CPOL" USART_InitStructure....... error: #136: struct "" has no fieild "USART_CPHA" USART_InitStructure. ...... error: #136: struct "" has no fieild "USART_LastBit" USART_InitStructure. ...... C: 0 Warnings , 5 Erroes |
RE:串行口配置时老是编译不过,请高手指点。谢谢!!
RE:串行口配置时老是编译不过,请高手指点。谢谢!!
从错误提示说明你所用的结构体里面根本没有定义USART_Parity,USART_Clock,USART_CPOL,USART_CPHA,USART_LastBit,问题就出在这里.在STM32的库里面他们是分开的两个结构体.我们在stm32f10x_usart.h里可以找到他们的定义,如下:
typedef struct
{
u32 USART_BaudRate;
u16 USART_WordLength;
u16 USART_StopBits;
u16 USART_Parity;
u16 USART_Mode;
u16 USART_HardwareFlowControl;
} USART_InitTypeDef;
/* USART Clock Init Structure definition */
typedef struct
{
u16 USART_Clock;
u16 USART_CPOL;
u16 USART_CPHA;
u16 USART_LastBit;
} USART_ClockInitTypeDef;
说到这里应该明白了吧?
不明白继续说,
初始化函数要用到USART_Parity,USART_Clock,USART_CPOL,USART_CPHA,USART_LastBit,那就要声明下
USART_ClockInitTypeDef USART_ClockInitStructure;
然后你的初始化就这样写
USART_ClockInitStructure.USART_Clock=USART_Clock_Disable;
USART_ClockInitStructure.USART_CPOL= USART_CPOL_Low;
USART_ClockInitStructure.USART_CPHA= USART_CPHA_2Edge;
USART_ClockInitStructure.USART_LastBit=USART_LastBit_Disable;
完 了.
回复:串行口配置时老是编译不过,请高手指点。谢谢!!
RE:串行口配置时老是编译不过,请高手指点。谢谢!!
回复:串行口配置时老是编译不过,请高手指点。谢谢!!
RE:串行口配置时老是编译不过,请高手指点。谢谢!!
回复:串行口配置时老是编译不过,请高手指点。谢谢!!
我重新又作了声明,还是不行,不然的化我打包让楼上的朋友帮助看一下。先谢谢了!
你打包传上来吧,我帮你看看。
回复:串行口配置时老是编译不过,请高手指点。谢谢!!
MINI_WTT.zip
2011-4-15 10:12 上传
点击文件名下载附件
648.63 KB, 下载次数: 0