cancel
Showing results for 
Search instead for 
Did you mean: 

RS485 communication problem between stm32f030 and stm32f103

pm_brk_pm
Associate II
Posted on November 15, 2016 at 10:44

 

 

The original post was too long to process during our migration. Please click on the attachment to read the original post.
3 REPLIES 3
pm_brk_pm
Associate II
Posted on November 15, 2016 at 11:35

Here is my server data view, first data from ''GNRMC'' to ''4D'' comes from gps module and ''3'' is a single data which comes from stm32f030 , But it should be ''3567''

0690X0000060MnaQAE.gif


Posted on November 16, 2016 at 07:31

Hi there,

I have noticed something simmilar on STM32F030 just yesterday. I made a test program just to send 3 bytes in halfduplex mode using DMA. The bytes were 1,2,3. On the receiver side I only obtained 01 00 00. And those two zeros, I am not sure, but I dont think thats actually any data sent but some line mismatch... Please let me know if you solve your problem.
pm_brk_pm
Associate II
Posted on November 23, 2016 at 07:54

Hi Bremen,

As I mentioned above, My assumption was considering stm32f0(Transmitter side via rs485) is ;Did not send or missing the relevant data.But I was getting response using 3 cable converter from putty. Therefore ,I focused to the receiver one(stm32f103) and I also used 3 cable converter for analyzing data flow in this part.Fortunately, I have verified that the data is correctly transmitted to this microcontroller.Then I focused to the reciever interrupt handler for usart1.The problem was, I reset buffer when each character is set to the char array.Thus it was getting only one character each time and only one character was indicating on server after resetting buffer. So, I used reset function of buffer in Interrupt handler as like this;

void USART1_IRQHandler(void)
{
if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)//Data available in the Read Register.
//if(USART1->SR & USART_SR_RXNE)
{
// GPIO_SetBits(GPIOB,GPIO_Pin_0);
//GPIO_WriteBit(GPIOB,GPIO_Pin_0, Bit_RESET);
char ch = rs485data.serialPort.getch();
// if(ch!=50){
if(ch!=10){
if(ch!=13){
rs485data.serialPort.rxTrailerbuffer[rs485data.serialPort.rxTrailerbufferReadCounter++]=ch;
}}
// } 
if(rs485data.rs485detect== false){
for (int i = 0;i<
rs485data.serialPort.rxTrailerbufferReadCounter
;i++){
TrailerData[i]=rs485data.serialPort.rxTrailerbuffer[i];
rs485data.serialPort.rxTrailerbuffer[i]=0;
}
TrailerData[rs485data.serialPort.rxTrailerbufferReadCounter]=0;
rs485data.rs485detect
=
true
;
rs485data.serialPort.rxTrailerbufferReadCounter
=
0
; //THIS ONE
// 
// if(rs485data.serialPort.rxTrailerbufferReadCounter>6){
// rs485data.serialPort.rxTrailerbufferReadCounter=0;}
}
//char ch = sp1.getch();
USART_ClearITPendingBit(USART1, USART_IT_RXNE);
}
}
}