| ??? 01/06/03 05:50 Read: times |
#35740 - RE: Code problem |
Craig:
Several suggestions for your code. Note that I do understand that you are a beginner programmer and so I just want to give a couple of ideas so that you do not experience similar problems in the future. 1) I think it would be a good idea for you to add some logic to the loop where you receive in the data from the serial port to check for how much data has been received and provide for a limit on how much you will take in. Make the limit a little longer than the length of the GGA NEMA sentence you are receiving. This makes your program have control over how much memory is used for the receive buffer and how far up in memory the buffer will extend. 2) You should consider the possibility of using the assembler pseudo ops that control the assembly process for code memory versus internal memory space. Then in the source at some place switch assembly to the internal data space and setup the data variables similar to as follows: (Note that your assembler syntax may differ somewhat).
MAX_SENTENCE EQU 32
DSEG AT 020H
SENTENCE_BUF:
DS MAX_SENTENCE
DELAY1_BYTE:
DS 1 ; outer loop counter for TD sub
DELAY2_BYTE:
DS 1 ; inner loop counter for TD sub
Now in your code instead of using hard coded internal memory addresses such as 020H, 030H and 031H, use the labels SENTENCE_BUF, DELAY1_BYTE and DELAY2_BYTE instead. In the place where you receive the data and do the limit checking on how much data has come in use the constant named MAX_SENTENCE as the value you check with. This way the buffer wont be overrun. And it is easy to change the size of the buffer in one place by changing the MAX_SENTENCE EQU value. Using these techniques you will learn how to let the assembler manage the memory addresses of your data space for you. And then most likely in your next program you will not encounter a problem like you have in the code you posted here for us to help you with. Good Luck !!! Michael Karas |
| Topic | Author | Date |
| Code problem | 01/01/70 00:00 | |
| RE: Code problem | 01/01/70 00:00 | |
| RE: Code problem | 01/01/70 00:00 | |
RE: Code problem | 01/01/70 00:00 |



