2019-10-06 10:56 PM
2019-10-07 06:32 AM
Sounds very work specific, perhaps you need a software developer on the team.
Perhaps start with getting the RS485 interface up, and then layer the protocol, and device specifics on top of that.
2019-10-08 08:58 PM
Can you help with modbus rtu
main.c file:-
#include "bsp.h"
#include"systick.h"
int main()
{
USART_INTERRUPT_CONFIGURATION(USART6,GPIOC,GPIO_PinSource6,GPIO_PinSource7,GPIO_Pin_6,GPIO_Pin_7,0,0);
char tmp[8];
tmp[0]=0x01;
tmp[1]=0x03;
tmp[2]=0xbd;
tmp[3]=0x02;
tmp[4]=0x02;
tmp[5]=0x00;
tmp[6]=0x01;
tmp[7]=0Xa6;
int i=0;
gpio_init(GPIOI,GPIO_Pin_8);
RS485_TX_ENABLE;
SEND_STRING(tmp,USART6);
}
Interrupt:-
st_buf Rbg={0,0,};
uint16_t S;
uint16_t slave,func,no_of_bytes,data_reg_hi,data_reg_Lo,crc1,crc2;
void USART1_IRQHandler (void)
{
//gpio_init(GPIOI,GPIO_Pin_11);
static st_buf *p;
//RS485_RX_ENABLE;
// RS485_TX_DISABLE;
p=&Rbg;
if ((USART_GetFlagStatus(USART1,USART_IT_RXNE)))
{
if( p->in!=RBUF_SIZE)
{
p->buf [p->in]=USART1->DR;
S = p->buf [p->in];
//gpio_init(GPIOH,GPIO_Pin_6)=S;
p->in++;
switch(S)
{
case 1:
slave=S;
break;
case 3:
func=S;
break;
case 0x02:
no_of_bytes=S;
break;
case 0:
data_reg_hi=S;
break;
case 0x2d:
data_reg_Lo=S;
break;
case 0x78:
crc1=S;
break;
case 0x59:
crc2=S;
}
}
}
}
protocol code? I am using usart interrupt & DMA functions and I find incomplete bits are transferring from the instruction set. Kindly help with Keil program codes. Thank you so much for the help.
2019-10-10 10:33 PM
@Community member Can you please help me this? I have mentioned the issue in the reply comment above.
2019-10-11 02:50 AM
Probably not. Not a library I'm familiar with. The logic in the IRQ Handler looks broken to me, and doesn't have code to address failure or error status from the USART.
Perhaps record the data stream actually observed and replay that through the logic used.