Have you searched the Forum?
this has been discussed many, many... times.
Have you searched the Forum?
this has been discussed many, many... times.
regards
Ralph
_______________________________________________
There are only 10 types of people:
Those who understand binary, and those who don't ...
_______________________________________________
In answer to your question: Yes I read every post I could find for about 3 days now.
I found the problem was in the interupt I believe and some variable handling.
My LCDs on both PICs seem to scramble after a little while. They come up mostly blacked out Characters with some garbage characters showing up randomly. I put .1 caps across the power in at the LCD and it seemed to slow it down some. Any ideas?
Hi ChadMan,
More than likely, the problem is related to the "Context Saving" in your interrupt routine.
Most often it's caused by saving the registers "Again".
If the PIC has more than 2K of program space then PBP automatically inserts the Context Save routine, then it's up to you to restore them at the end of the interrupt.
So, if you're saving them again with something like this.Then you are overwriting the values that have already been saved. And, when they get restored, PBP get's very confused.Code:myint movwf wsave swapf STATUS, W clrf STATUS movwf ssave movf PCLATH, W movwf psave
If that's the case, simply remove that section, and it should work much better.
HTH,
Darrel
Looking thru the ASM generated by PBP, I could not find anything related to the PCLATH. Here is what I have working with the Help of MELabs of course (Thanks Mr. Leo!):
If that's the case, simply remove that section, and it should work much better.
HTH,
Darrel
I am using MPasm to assemble the PBP code. The only thing I see related to the inerupt in the ASM is here:Code:Adcon1 = 6 'disable analog comparator TRISA = %11111111 'Set Port A to inputs pir1.5 = 0 ' clearing interrupt flags Mess Var Byte '____________________Main_____________________ Start: PicRecieve: If PIR1.5 = 1 then Pic_serin Goto PicRecieve Pic_serin: Hserin [Mess] IncomingM: If Mess= %00000001 Then mess1 If mess= %00000010 Then mess2
<div class="smallfont" style="margin-bottom:2px">Code=</div>
<pre class="alt2" style="margin:0px; padding:6px; border:1px inset; width:600px; height:225px; overflow:auto">PicBasic Pro Compiler 2.45a, (c) 1998, 2004 microEngineering Labs, Inc. All Rights Reserved.
_USED EQU 1
INCLUDE "C:\PBP\16F870.INC"
; Define statements.
#define CODE_SIZE 2
#define LCD_DREG PORTB
#define LCD_DBIT 0
#define LCD_RSREG PORTB
#define LCD_RSBIT 4
#define LCD_EREG PORTB
#define LCD_EBIT 5
RAM_START EQU 00020h
RAM_END EQU 000BFh
RAM_BANKS EQU 00002h
BANK0_START EQU 00020h
BANK0_END EQU 0007Fh
BANK1_START EQU 000A0h
BANK1_END EQU 000BFh
EEPROM_START EQU 02100h
EEPROM_END EQU 0213Fh
R0 EQU RAM_START + 000h
R1 EQU RAM_START + 002h
R2 EQU RAM_START + 004h
R3 EQU RAM_START + 006h
R4 EQU RAM_START + 008h
R5 EQU RAM_START + 00Ah
R6 EQU RAM_START + 00Ch
R7 EQU RAM_START + 00Eh
R8 EQU RAM_START + 010h
FLAGS EQU RAM_START + 012h
GOP EQU RAM_START + 013h
RM1 EQU RAM_START + 014h
RM2 EQU RAM_START + 015h
RR1 EQU RAM_START + 016h
RR2 EQU RAM_START + 017h
_Mess EQU RAM_START + 018h
_PORTL EQU PORTB
_PORTH EQU PORTC
_TRISL EQU TRISB
_TRISH EQU TRISC
#define _PIR1_5 PIR1, 005h
INCLUDE "R2_PIC.MAC"
INCLUDE "C:\PBP\PBPPIC14.LIB"
MOVE?CB 006h, ADCON1
MOVE?CB 0FFh, TRISA
MOVE?CT 000h, _PIR1_5
LABEL?L _Start
LABEL?L _PicRecieve
CMPEQ?TCL _PIR1_5, 001h, _Pic_serin
GOTO?L _PicRecieve
LABEL?L _Pic_serin
HSERIN?B _Mess
LABEL?L _IncomingM
CMPEQ?BCL _Mess, 001h, _mess1
CMPEQ?BCL _Mess, 002h, _mess2
LABEL?L _mess1
PAUSE?C 001F4h
LCDOUT?C 0FEh
LCDOUT?C 001h
LCDOUT?C 048h
LCDOUT?C 065h
LCDOUT?C 06Ch
LCDOUT?C 06Ch
LCDOUT?C 06Fh
PAUSE?C 005DCh
LCDOUT?C 0FEh
LCDOUT?C 001h
RETURN?
LABEL?L _mess2
PAUSE?C 001F4h
LCDOUT?C 0FEh
LCDOUT?C 001h
LCDOUT?C 047h
LCDOUT?C 06Fh
LCDOUT?C 06Fh
LCDOUT?C 064h
LCDOUT?C 062h
LCDOUT?C 079h
LCDOUT?C 065h
PAUSE?C 005DCh
LCDOUT?C 0FEh
LCDOUT?C 001h
RETURN?
END?
END</div></pre>
How long a cable do you think I can get away with? I am trying to evolving this into a paging system (functional learning project) and was thinking of using 100' of Telephone wire. Too far? Or would it be better to use a twisted pair like the Cat5 wire?
Thanks Darrel
ChadMan
Hmmm,
Your first message stated that you had a problem with the Interrupt routine.
Now I can see that you didn't have any interrupt routines, even though you had enabled Interrupts. So what I said previously, doesn't apply.
As for the Maximum RS232 distance. The spec says 50ft max. But it really depends on the baud rate. I've run it up to 200' with 2400 baud.
If you put an RS485 convertor on both ends, you can go up to 4000'
Darrel
Bookmarks