CH375B与STM32通信问题

1、执行xWriteCH375Cmd(CMD_GET_IC_VER);返回B7,说明单片机和CH375B通信正常了;

2、执行xWriteCH375Cmd(CMD_CHECK_EXIST);

       xWriteCH375Data(0xaa);

       i = xReadCH375Data();

   没有反应,不回复,也不报错;

硬件说明:我硬件上是按TXD,RXD,GND这种方式接的,我想接STA,INT这种方式,但在手册上找不到STA引脚对应CH375B第几号脚?

3、我在发命令前加上两个同步码0x57,0xAB后会返回05F,如果这种三线制没有同步码,怎么区分数据和命令指令;

4、串口的设定参数我看到文档上写着是4800,但我程序要设为9600才能通信,不知CH375B默认的串口设定是一个什么情况;

下面是我串口的设定,麻烦帮我看一下有什么时候问题:

void USART_Configuration(void)

{

USART_InitTypeDef USART_InitStructure;

USART_ClockInitTypeDef USART_ClockInitStructure;


RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);   


USART_InitStructure.USART_BaudRate   = 9600;   

USART_InitStructure.USART_WordLength = USART_WordLength_9b; 

USART_InitStructure.USART_StopBits   = USART_StopBits_1;   

USART_InitStructure.USART_Parity     = USART_Parity_Even;   

USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;

USART_InitStructure.USART_Mode       = USART_Mode_Rx|USART_Mode_Tx;


USART_Init(USART2, &USART_InitStructure);  

/* The following example illustrates how to configure the USART1 Clock */

USART_ClockInitStructure.USART_Clock = USART_Clock_Disable;

USART_ClockInitStructure.USART_CPOL = USART_CPOL_High;

USART_ClockInitStructure.USART_CPHA = USART_CPHA_1Edge;

USART_ClockInitStructure.USART_LastBit = USART_LastBit_Enable;

USART_ClockInit(USART2, &USART_ClockInitStructure);

/* Enable USART1 */

USART_Cmd(USART2, ENABLE);    

void USART2_Send_Byte(u8 OneByte)

{

/* Write one byte in the USART1 Transmit Data Register */

USART_SendData(USART2, OneByte);

/* Wait until end of transmit */

while(USART_GetFlagStatus(USART2, USART_FLAG_TC) == RESET);

USART_ClearFlag(USART2, USART_FLAG_TC);

}

UINT8 xReadCH375Data( void )

{

UINT8 Dat;

Dat = RxBuff[0];

return Dat;

}


void xWriteCH375Cmd( UINT8 mCmd )

{

USART2_Send_Byte(mCmd);

}


void xWriteCH375Data( UINT8 mData )

{

USART2_Send_Byte(mData);

DelayUs(2);

}



已建议使用CH376芯片


只有登录才能回复,可以选择微信账号登录