Importing MODBUS code into Microcontroller


Thread Starter


I am a newbie to microcontroller and am so confused how to import modbus master code to my microcontroller. Modbus code comes in different programming languages, say for example "C", but, how does the microcontroller know that it uses C language? And how to program the microcontroller, so that it understands modbus language and to configure the device to a modbus device?

-Thanks in Advance

Curt Wuollet

Really, what happens is the C has to know the microprocessor at least to some extent. That is the the C code is compiled to the machine code for that type of processor. So to write C code for a microprocessor you compiler that has been ported to that processor family. Most microprocessor manufacturers have such a compiler they will sell you, but before I went that way I would check for a GNU C Compiler for that processor. C without an operating system, that is, embedded C is written very close to the silicon, meaning that to use it effectively you need to know a lot about the registers and pin muxes and the like. Unless you must code at that level, if you just want to run modbus code it would be much easier to use an SBC with an operating system like Linux (the leading embedded system) as much of the detail is handled by the OS. For example, it would be fairly easy to take a Raspberry pi and run the Modbus sample code on the Modbus site. To run that on a bare micro you would need to write a great deal of support code.