您的位置:首页 > 其它

关于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);

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: