Modbus CRC16

Thread Starter

geoffers

Joined Oct 25, 2010
490
Hi all,
Got a bit out of my depth here, I'm trying to make a PIC16f1827 communicate with some inverters via rs485 modbus protacal.

I've got really stuck on how to implement the Modbus crc.

I write in MPASM and got an730 to try and get going

The Modbus crc works a bit differently I think could anyone point me towards a ASM modbus crc calculator or at least in the right direction.

I've tried googling it but just keep ending up with c examples which I don't use.

I'd be happy to use a lookup table.

Thanks Geoff
 

Thread Starter

geoffers

Joined Oct 25, 2010
490
Another query on this, I'm using a pic16f1827 , I need to receive modbus reply's from the inverter.
I've not used the receive function much on the UART, normally only TX, I did make a ring buffer for talking to Bluetooth modules once with a different pic.
My function reads the expected number of bytes from the UART module, I turn it on just after transmission of my first sentence.
I seem to receive two bytes of junk first? Is it good practice to flush the buffer just after turn on? I'm polling rcif before I read them, just curious where they come from??

Cheers Geoff
 
Top