Hi Shawn
The only place I have some doubts is this
Code:
while (PIR1.5 = 1) 'Write modbus frame to buffer
buffer[Length] = RCREG
Length = Length + 1
if Length = 75 then
Length = 0
EndIf
wend
I would rather let the ISR exit immediately after collecting and buffering the character. Keeping it in the while:wend means it will not exit the ISR and also will not be able to keep time in the timer ISR branch. Set length=1 only when you start collecting a newframe. Rest of the time, the ISR will collect a character, increment length, etc
A strategy I use to check such types of communications
Repeatedly Send a modbus message to the PC running brayTerm in Hex mode. this will obviate any Tx/Rx timing and baud rate issues
Once you have this running easy, work on the Rx part where the PC sends a fixed modbus message. the PIC will indicate a proper packet received by a flash of led.
Done that, now let it run in a command-response format. It's bound to work.
Bookmarks