What's the protocol for altering CODE?

camerart

Solid State Member
Messages
13
Location
Uk
Hi,
I've been programming since early 80s, but much of it doesn't sink in I'm afraid.


I am writing, (with great help from others who help me, like here) a program on a PIC using Oshonsoft BASIC. There is an INTERRUPT that was written for me, and I almost understand how it works, but now after my tinkering, I have to re-write it.


Here is the INTERRUPT.
----------------------------------------------------------
On High Interrupt
Save System

If RCSTA.OERR = True Then 'any error reboot serial module..
RCSTA.CREN = 0
RCSTA.CREN = 1
valid = 0
rxin = 0
Goto jump
Endif

If str_done = 1 Then
char = RCREG 'temp = RCREG 'Simply dump the character'CCCCCCCCCCCCCCCCCCCCC
Goto jump 'Completed string has not been processed yet by MAIN program
Endif


char = RCREG 'temp = RCREG'CCCCCCC
'Now check for valid string to save. Must contain $ (GNRMC) at first, then read rest until EOL
Select Case rxin
Case 0 'Must be $ sign
If char = "$" Then
str1(rxin) = char
valid = 1
Else
valid = 0
rxin = 0
Endif
Case Else


If valid = 1 Then str1(rxin) = char 'buffer(rxin) = temp 'get character(reading clears the RCIF)CCCCCCCC

EndSelect

If str1(rxin) = "?" Or str1(rxin) = 0x0a Then 'If buffer(rxin) = "?" Then
valid = rxin 'set length of valid string
str_done = 1 'Flag we have a completed string. Main program to check for this and process
Goto msg_eol 'Jump out of the INTERRUPT ROUTINE
Else
If valid = 1 Then rxin = rxin + 1
If rxin = 80 Then
rxin = 0 '80 position circular buffer. If overflow, start from scratch
valid = 0
Endif
Endif
jump:

Resume

----------------------------------------------------------
There are BIT FLAGS and lines that I have difficulty with.


My question is, if a section of almost working CODE needed re-writing, what is the procedure to work through it, please? Remember, I'm not much of a programmer :(


Camerart.
 
Top