关于Rs485通信只能接收不能发送的问题
2016-08-18 19:31
543 查看
在485传输方向正确的前提下
//MAX3485数据传输方向
void MAX3485_DIRECTION(u8 direction)
{
if(direction == MAX3485_Send)
{
//高电平发送
GPIO_WriteBit(MAX3485_DIRC_GPIO, MAX3485_DIRECTION_OUT, Bit_SET);
delay_ms(5);
}
if(direction == MAX3485_Receive)
{
//低电平接收
GPIO_WriteBit(MAX3485_DIRC_GPIO, MAX3485_DIRECTION_OUT, Bit_RESET);
delay_ms(5);
}
}
依然不能发送,但是接收正确。
后来发现屏蔽掉初始化所有的引脚为腿挽输出的代码后,就可以了。
void SetPinDefault()
{
GPIO_InitTypeDef m_all_GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC,ENABLE);
//设置GPIOA设置为推挽输出
m_all_GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
m_all_GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
m_all_GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOA,&m_all_GPIO_InitStructure);
//设置GPIOB设置为推挽输出
m_all_GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
m_all_GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
m_all_GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB,&m_all_GPIO_InitStructure);
//设置GPIOC设置为推挽输出
m_all_GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
m_all_GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
m_all_GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOC,&m_all_GPIO_InitStructure);
}
//MAX3485数据传输方向
void MAX3485_DIRECTION(u8 direction)
{
if(direction == MAX3485_Send)
{
//高电平发送
GPIO_WriteBit(MAX3485_DIRC_GPIO, MAX3485_DIRECTION_OUT, Bit_SET);
delay_ms(5);
}
if(direction == MAX3485_Receive)
{
//低电平接收
GPIO_WriteBit(MAX3485_DIRC_GPIO, MAX3485_DIRECTION_OUT, Bit_RESET);
delay_ms(5);
}
}
依然不能发送,但是接收正确。
后来发现屏蔽掉初始化所有的引脚为腿挽输出的代码后,就可以了。
void SetPinDefault()
{
GPIO_InitTypeDef m_all_GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC,ENABLE);
//设置GPIOA设置为推挽输出
m_all_GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
m_all_GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
m_all_GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOA,&m_all_GPIO_InitStructure);
//设置GPIOB设置为推挽输出
m_all_GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
m_all_GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
m_all_GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB,&m_all_GPIO_InitStructure);
//设置GPIOC设置为推挽输出
m_all_GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
m_all_GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
m_all_GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOC,&m_all_GPIO_InitStructure);
}
相关文章推荐
- msmq在Internet上访问的问题(只能发送,不能接收)
- 解决ios设备自带邮箱只能接收邮件不能发送邮件问题的方法
- 关于linux下的udp/tcp通信设置发送sendto/接收recvfrom信息超时的参数。解决通道堵塞问题。
- msmq在Internet上访问的问题(只能发送,不能接收)
- 解决雅虎邮箱使用outlook只能收不能发送的问题(针对yahoo.com.cn)
- 关于Data Collector只能禁用,且不能删除其job的问题
- outlook 2007 邮箱只能接收不能发送邮件
- 关于解决spring 只能跳转到.jsp 不能跳转到.html的问题
- 关于cocos2d-x 触屏事件不能接收的问题
- 关于saba不能发送中文邮件问题解决
- 关于重复接收NSNotificationCenter发送的通知的问题
- Mac自带mail客户端只能收不能发送邮件问题解决
- 关于:Android 如何发送/接收DTMF问题
- SmartSniff只能截取接收包,不能截取发送包
- outlook2003只能发送邮件不能接收
- 关于使用VBS脚本不能发送密码的问题
- 关于Jmail不能发送邮件问题
- c++和java在socket通信过程中发送和接收函数的问题
- 关于调试程序接收通过adb发送带有参数的广播问题
- 关于UDP向本机端口发送数据报但是接收不到数据的问题