1、執(zhí)行xWriteCH375Cmd(CMD_GET_IC_VER);返回B7,說明單片機和CH375B通信正常了;
2、執(zhí)行xWriteCH375Cmd(CMD_CHECK_EXIST);
? ? ? ?xWriteCH375Data(0xaa);
? ? ? ?i =?xReadCH375Data();
? ?沒有反應(yīng),不回復(fù),也不報錯;
硬件說明:我硬件上是按TXD,RXD,GND這種方式接的,我想接STA,INT這種方式,但在手冊上找不到STA引腳對應(yīng)CH375B第幾號腳?
3、我在發(fā)命令前加上兩個同步碼0x57,0xAB后會返回05F,如果這種三線制沒有同步碼,怎么區(qū)分數(shù)據(jù)和命令指令;
4、串口的設(shè)定參數(shù)我看到文檔上寫著是4800,但我程序要設(shè)為9600才能通信,不知CH375B默認的串口設(shè)定是一個什么情況;
下面是我串口的設(shè)定,麻煩幫我看一下有什么時候問題:
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);
}