Read This First
Read This First
| \/ | | | | / ___| |
| . . | ___ __| | |__ _ _ ___ \ `--.| | __ ___ _____
| |\/| |/ _ \ / _` | '_ \| | | / __| `--. \ |/ _` \ \ / / _ \
| | | | (_) | (_| | |_) | |_| \__ \ /\__/ / | (_| |\ V / __/
\_| |_/\___/ \__,_|_.__/ \__,_|___/ \____/|_|\__,_| \_/ \___|
This project contains the code to get ANY PIC18F series Microcontroller
with a working USART to act as a Modbus Slave device.
From here you can start coding away in "main.c" and start adding your
own functions to "user.c".. all you need to do is equate a holdinReg
or a coil to something.
For example
void main(void)
{
OpnUSART();
ConfigInterrupts();
while(1){
if(modbusMessage){
decodeIt();}
TRISD,TRISC = 0;
LATD = holdingReg[0];
LATCbits.LATC1 = coils[0];
}
}
Obviously you can take it further than this and start making cool functions
but that is up to you.. all of the communication code is taken care for you.
You will need to make your own ifdef for your processor.. containing the
relevant configurations and options.
There are 2 more places that the ifdefs will be needed to be changed and that
is in all of the functions inside "system.c" and in "configurationbits.c"
If you look inside the ifdefs in these 2 files it should be clear what they
do and what you will need to change to get it working on your processor..
Then I would go to the bottom of system.h and make an ifdef use case for the
p18f4550, leaving the other 2 ifdefs intact..
I would then go into system.c and add my own ifdef to all the functions and
finally create an ifdef in the configuration bits file.. that is all.