2020-04-25 02:12 AM
Hello Everyone,
This problem is persisting. I am using the STM8L151 Standard Peripheral Library to send an array of bytes over USART1. Code executes, but i see nothing on the Pin (using Oscilloscope), nor can i see the Data Rigister changing (Using ST Visual Develop, and ST Link V2 Debugger).
Can anyone see why it behaves so? -anyone made a similar ugly experience before?
thanks in advance
Here is my code inside the main:
case State_Comm_Tx:
if (State_Entrance_Part_F==0)
{
State_Entrance_Part_F=ON;
Init_USART_Tx();
//Prepare the Array to send
//uint8_t Meas_Update[6];
Meas_Update[0]= Start_Of_Text;
Meas_Update[1]= 7; // Message Length
Meas_Update[2]=0x01; // Meassage Identifier
Meas_Update[3]= (u8) (Echo_FlyDist>>8);
Meas_Update[4]= (u8) Echo_FlyDist;
Meas_Update[5] = 0x04;
Meas_Update[6]= End_Of_Text;
USART_ClearFlag(USART1, USART_FLAG_TC);
}
if(State_Entrance_Part_F)
{
uint8_t Parameter_Nr=0;
uint8_t Tx_Array_Size= sizeof(Meas_Update);
USART_GetFlagStatus(USART1, USART_FLAG_TXE);
for(Parameter_Nr=0; Parameter_Nr< Tx_Array_Size; Parameter_Nr++)
{
while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET)
{}
USART_SendData8(USART1, Meas_Update[Parameter_Nr]);
}
State_Entrance_Part_F=0;
Active_State=State_Pulse_Tx;
}
break;
-------------------------------------
And the Initializsation of the USART , i do with the following function:
void Init_USART_Tx(void)
{
USART_DeInit(USART1);
CLK_PeripheralClockConfig(CLK_Peripheral_USART1,ENABLE);
USART_HalfDuplexCmd(USART1, DISABLE);
GPIO_Init(GPIOA,GPIO_Pin_2, GPIO_Mode_Out_PP_High_Fast ); // USART_Tx Pin set as output
USART_Init(USART1,115200,USART_WordLength_8b, USART_StopBits_1, USART_Parity_No, USART_Mode_Tx);
USART_Cmd(USART1,ENABLE);
}
-------------------------------------------
Thanks for your feedback