Go Back   Computer Forums > General Computing > Software and Operating Systems
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 03-08-2020, 05:20 AM   #1
Solid State Member
 
Join Date: May 2017
Location: Uk
Posts: 12
Default What's the protocol for altering CODE?

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.
__________________
camerart is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 05:46 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0
×