PDA

View Full Version : 2k barrier variable problems



khufumen
- 19th December 2004, 14:59
I am working with a PIC16F876 using PBP. My program consists of about 6000+ words. I have declared all my variables at the start of the progam and used the CLEAR command also. After declaring a variable and setting it to a number (ie. X = 10) If I do a SEROUT2 command such as SEROUT2 TX, Baudrate, ["X= ", DEC X, 13, 10]

I get the following response:
X=


However if I limit my program to 2000 words, I get
X=10

I cannot figure out what is causing this problem. Any help would be greatly appreciated.

Kind Regards,
Eric

mister_e
- 19th December 2004, 22:51
Are you using some BRANCH or assembler interrupt ??

Wich version of PBP are you using.

Can you try place some variable into BANK 0

MYVAR var byte BANK0

khufumen
- 20th December 2004, 01:53
Below is the code that is causing the grief. It is evidently not a 2k barrier problem but has to do with the SEROUT2 command. If I run the simple code shown below, the HyperTerminal shows:

I:
J:

If I then get rid of the second SEROUT2 command, the Hyperterminal shows:

I: 4
I: 56

It appears that the timeout, label of the second SEROUT2 command destroys the variable. Although I am not using the second SEROUT2 command, it's presense seems to effect the variables.

I would be curious if you tried this yourself. It's either a bug or a possible problem with using PORTA pins of the 16F876.

Kind Regards,
Eric



DEFINE OSC 20 ' define oscillator to be 20Mhz
ADCON1 = 7 ' set the analog pins to digital

' serial connections
RX VAR PORTA.3 ' receive (from PC)
TX VAR PORTA.2 ' transmit (to PC)
CTS VAR PORTA.1 ' clear to send
RTS VAR PORTA.0 ' request to send

' General variables
I VAR byte ' general variable
J var byte
BaudRate var word

'Baud rate constants
Baud96 CON 16468 ' 9.6K baud rate


'1. set baud rate to 38400
BaudRate = Baud96


I = 4
J = 56

Main:
pause 1000
SEROUT2 TX, BaudRate,["I: ", DEC I, 13, 10,"J: ", DEC J, 13, 10]
goto Main

SEROUT2 TX\CTS, BaudRate, 200, NoData, ["Test"]
NoData:
Goto Main

mister_e
- 20th December 2004, 18:39
Hi Eric,

I got the same results here. Certainely not PORTA problem. I test it. Problem is the flow control... why not simply skip this and send it straight??? Can be safe to make some character pacing.

I try different stuff to make it work... NADA. Trying only one SEROUT2 + flow control... Send only "I: " I miss certainely something here but...

In all my apps, since the begining, i'd never use any kind of flow control. At this time, never had any problem with them too.

Sorry !!!

If you find something, let me know.

Anybody got great results with flow control option with SEROUT2 here ???

regards

Bruce
- 20th December 2004, 21:18
I found the same problem. If I remove the timeout value and label in the SEROUT2 line with flow control it works.



DEFINE LOADER_USED 1
DEFINE OSC 20 ' define oscillator to be 20Mhz
ADCON1 = 7 ' set the analog pins to digital
RX VAR PORTC.7 ' receive (from PC)
TX VAR PORTC.6 ' transmit (to PC)
CTS VAR PORTC.1 ' clear to send
RTS VAR PORTA.0 ' request to send

' General variables
I VAR byte
J var byte
K VAR BYTE
L VAR BYTE
M VAR BYTE
N VAR BYTE
I = 7
J = 8
K = 9
L = 10
M = 11
N = 12

Main:
SEROUT2 TX, 84,["I: ", DEC I, 13, 10, "J: ", DEC J, 13, 10]
SEROUT2 TX, 84,["K: ", DEC K, 13, 10, "L: ", DEC L, 13, 10]
SEROUT2 TX, 84,["M: ", DEC M, 13, 10, "N: ", DEC N, 13, 10]
pause 1000
goto Main

NoData:
' The line below does not work
SEROUT2 TX\CTS, 84, 200, NoData, ["Test"]
' This one below works if above is commented out
' SEROUT2 TX\CTS, 84, ["Test"]
Goto Main
With the timeout and label options used in the NoData routine, the Main routine sends;
I: 7
J:
K: 9
L:
M: 11
N:

Comment out the timeout & label line, un comment the lower, and it works sending this;

I: 7
J: 8
K: 9
L: 10
M: 11
N: 12

Seems to always trash the 2nd variable with flow control and the timeout/label options used in NoData.

I sent Jeff at MeLabs an email. He's looking into it.

khufumen
- 20th December 2004, 22:00
Hey, thanks for all your input. At least I know I am not crazy. I'll abandon flow control for the time being but would be very interested in what metlabs has to say.

Regards,
Eric

Bruce
- 20th December 2004, 23:02
Big thanks to Jeff at MeLabs for the super fast fix to this one.

Here's the fix.

Open your PBPPIC14.LIB file.

Add the following 3 lines of assembler starting at line 5011 in PBPPIC14.LIB:


ifdef SEROUT2TO_USED
bsf STATUS, C ; Set carry for no timeout in case of blanking
endif


When finished it should look like this from line 5010 to 5019;


serout2send1 movf R0, W ; Get char back
ifdef SEROUT2TO_USED
bsf STATUS, C ; Set carry for no timeout in case of blanking
endif
btfss STATUS, Z ; If zero, goto blank check
bcf GOP, 7 ; Not zero so clear blank
btfsc GOP, 7 ; If blanking on, don't send
return
addlw '0' ; Add ASCII offset
goto JUMPMAN ; Send it

NavMicroSystems
- 20th December 2004, 23:34
Great !

Isn't this somthing that should go to the FAQ section?

Subject: SERIN2 FlowControl / TimeOut . . .

regards:

Ralph

khufumen
- 20th December 2004, 23:35
Bruce,

Thank you very much for the speed in solving this issue. I tried it out and it works great! I would thank Jeff personally but I don't know his email. Please pass on my thanks.

Kind Regards,
Eric