Memory Overflow? Urgently need advice


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2010
    Posts
    5

    Default Memory Overflow? Urgently need advice

    Hi guys, Im getting the message[306] crossing page boundary problem..

    Im using a pic16F88 and it has a total amount of 9777+ asembly lines

    Ive been googling and it seems that means that my pic16F88 has not sufficient memory to hold the program, however I feel like the program is very simple and straight forward.

    So Im here looking for advice on ways to make the program fit onto my pic or should i get an 18X series. The code is approximately 257 lines but please give me an advice or two if possible! It will be greatly appreciated!

    The main issue - without codeReset program, theres no memory overflow; with codeReset program it overflows

    Code:
    DEFINE OSC 8
    OSCCON.4 = 1 'Sets the internal oscillator frequency to 8 MHz
    OSCCON.5 = 1
    OSCCON.6 = 1
    
        'Turns off analog to digital conversion. Refer to
                    'Threaded Design Example A.4 p.296-299 of the textbook
                     'for an example of how to configure and use A/D conversion
    '====End header for PIC16F88==========
    '
    '========knock.code=========
    ' picking up signal from microphone, and then indicating it through the LED
    
    Include "bs2defs.bas" 		'includes bs2 definitions for the xband motion sensor
    
    'Pin Definitions
    TRISA = %01011				'ports 0,1,3 are inputs & 2,4 are outputs
    TRISB = %01101100			'ports 2,3,5 are inputs & rest are outputs
    'PORTA's					'Keypad input and LCD output 
    ede1144 VAR PORTA.0			'transmit line from ede1144
    ede1144Signal VAR PORTA.1	'valid line from ede1144
    LCD VAR PORTA.2
    xbandOutPin VAR PORTA.3		'x-band motion sensor output pin into PIC
    xbandEnPin VAR PORTA.4 		'x-band motion sensor input EN pin out of PIC
    'PORTB's
    buzzer VAR PORTB.1 			'Buzzer alarm output
    empty VAR PORTB.2  			'unsure yet
    arduin1 VAR PORTB.3 			'arduino input
    arduin2 VAR PORTB.4 			'output to arduino
    arduin3 VAR PORTB.5 			'xband arduino output?
    motor VAR PORTB.6			'motor output
    
    'Variables.
    LOW buzzer
    'this is for the xband
    motionThresh CON 2
    cycles VAR word
    reps VAR word
    halfSecond CON 500
    LOW xbandEnPin
    'this is for counter
    i VAR byte
    'this is for the keypad
    keyValue VAR byte
    keyValue1 VAR byte
    keyCode VAR byte[6]		'keycode array
    keyCode[0] = $35			'initial keycode
    keyCode[1] = $36
    keyCode[2] = $36
    keyCode[3] = $37
    keyCode[4] = $36
    keyCode[5] = $37
    keyCodeInput VAR byte[6]
    keyReceived VAR byte 	'keypad input
    keyReceived1 VAR byte
    x VAR byte	'counter for number of tries
    
    
    'power saving mode for LCD
    SEROUT2 LCD,32,[$FE,$46 ]	'sends string to LCD to shut LCD
    
    'main program
    main:
    'xband motion sensor
    HIGH xbandEnPin				'start the motion sensor when power is supplied
    i = 0							'sets i as 0
    If (arduin1 = 1) then motorOn			'if input detected from arduino ; code accepted goto motor
    If (xbandEnPin == 1 ) then
    	COUNT xbandOutPin, halfSecond, cycles	'count the output from motion sensor
    	If (cycles > motionThresh) then
    		For i = 0 to 1
    		HIGH buzzer								'sound buzzer twice to show that motion has been detected
    		pause 150								'pause 0.2 secs
    		LOW buzzer	
    		next i	
    	SEROUT2 LCD,32,[$FE,$42,0 ]					'turns on LCD
    	goto lcdMenu
    else
    	goto main									'loops back to main
    endif:endif			
    End			
    
    'once motion has been detected, lcd starts
    lcdMenu:
    
    SEROUT2 LCD,32,[$FE,$40, "Welcome Home Mr. Mecha!  ",$FE,$52 ]		'the startup message
    pause 1000
    SEROUT2 LCD,32,[$FE,$58, "Please Knock or Select Method of Input" ] 'the method of input is selected
    pause 500
    SEROUT2 LCD,32,[$FE,$58,$FE,$52, "1) Keypad Code", $FE,$47,(1),(0), "2) Manually" ]		'turns on LCD
    pause 100
    Serin EDE1144, 0, keyValue
    If (keyValue = $30 ) Then keypadCODE
    If (keyValue = $31 ) Then
    serout2 LCD,32,[$FE,$58,"Welcome Home!",$FE,$52 ]		'message
    pause 1500
    SEROUT2 LCD,32,[$FE,$46 ]	'sends string to LCD to shut LCD
    endif
    goto main
    
    'keypad entry
    keypadCODE:
    serout2 LCD,32,[$FE,$58,"Please enter 6-digit keycode",$FE,$52 ]		'ask for 6 digit keycombination
    i = 0			
    Serin EDE1144, 0, keyValue
    if (keyValue != $46 ) then
    			if (keyValue = $30 )then
    			keyReceived = keyValue
    			else 
    				if(keyValue = $31 )then
    				keyReceived = keyValue
    			else 
    				if(keyValue = $32 )then
    			keyReceived = keyValue
    			else 
    				if(keyValue = $33 )then
    			keyReceived = keyValue
    			else 
    				if(keyValue = $34 )then
    			keyReceived = keyValue
    			else 
    				if(keyValue = $35 )then
    			keyReceived = keyValue
    			else 
    				if(keyValue = $36 )then
    			keyReceived = keyValue
    			else 
    				if(keyValue = $37 )then
    			keyReceived = keyValue
    			else 
    				if(keyValue = $38 )then
    			keyReceived = keyValue
    			else 
    				if(keyValue = $39 )then
    			keyReceived = keyValue
    			else 
    				if(keyValue = $41 )then
    			keyReceived = keyValue
    			else 
    				if(keyValue = $44 )then
    			keyReceived = keyValue
    		endif : endif : endif : endif : endif : endif : endif : endif : endif : endif : endif : endif :
    		keyCodeInput[i] = keyReceived
    		i = i + 1
    else
    		serout2 LCD,32,[$FE,$58,"Code Entered, Please wait while it validates",$FE,$52 ]		'confirms entry
    		pause 150
    		For i = 0 to 1
    		HIGH buzzer								'sound buzzer twice to show that motion has been detected
    		pause 150								'pause 0.2 secs
    		LOW buzzer	
    		next i	
    endif
    i = 0
    for i = 0 to 5
    		if ( keyCodeInput[i] != keyCode[i] ) then revalidation
    next i 
    serout2 LCD,32,[$FE,$58,"Would you like to set a new Combination?",$FE,$52 ]		'confirms entry
    pause 500
    SEROUT2 LCD,32,[$FE,$58,$FE,$52, "1) Yes", $FE,$47,(1),(0), "2) No" ]		'turns on LCD
    pause 500
    if (keyValue = $30 ) then 
    	gosub codeReset
    endif
    if (keyValue = $31 ) then motorOn
    
    codeReset:
    serout2 LCD,32,[$FE,$58,"Please input new combination up to 6 numbers",$FE,$52 ]		'confirms entry
    i = 0		
    Serin EDE1144, 0, keyValue1
    if (keyValue1 != $46 ) then
    			if (keyValue1 = $30 )then
    			keyReceived1 = keyValue1
    			else 
    				if(keyValue1 = $31 )then
    				keyReceived1 = keyValue1
    			else 
    				if(keyValue1 = $32 )then
    			keyReceived1 = keyValue1
    			else 
    				if(keyValue1 = $33 )then
    			keyReceived1 = keyValue1
    			else 
    				if(keyValue1 = $34 )then
    			keyReceived1 = keyValue1
    			else 
    				if(keyValue1 = $35 )then
    			keyReceived1 = keyValue1
    			else 
    				if(keyValue1 = $36 )then
    			keyReceived1 = keyValue1
    			else 
    				if(keyValue1 = $37 )then
    			keyReceived1 = keyValue1
    			else 
    				if(keyValue1 = $38 )then
    			keyReceived1 = keyValue1
    			else 
    				if(keyValue1 = $39 )then
    			keyReceived1 = keyValue1
    			else 
    				if(keyValue1 = $41 )then
    			keyReceived1 = keyValue1
    			else 
    				if(keyValue1 = $44 )then
    			keyReceived1 = keyValue1
    		endif : endif : endif : endif : endif : endif : endif : endif : endif : endif : endif : endif :
    		keyCode[i] = keyReceived1
    		i = i + 1
    else
    		serout2 LCD,32,[$FE,$58,"Stored succefully! ",$FE,$52 ]		'confirms entry
    		For i = 0 to 1
    		HIGH buzzer								'sound buzzer twice to show that entry code is a success
    		pause 150								'pause 0.15 secs
    		LOW buzzer	
    		next i	
    endif
    return
    
    revalidation:
    x=0
    serout2 LCD,32,[$FE,$58,"Error, Please re-enter 6-digit keycode",$FE,$52 ]		'ask for 6 digit keycombination
    HIGH buzzer
    pause 150
    LOW buzzer
    	if( x < 3 ) then
    		x = x + 1
    		goto keypadCODE
    	else 
    		serout2 LCD,32,[$FE,$58,"INTRUDER ALERT!! INTRUDER ALERT!!",$FE,$52 ]
    		For i = 0 to 10
            HIGH buzzer
    		pause 150
    		LOW buzzer
    		next i
    	endif
    
    'motor setup
    motorOn:
    serout2 LCD,32,[$FE,$58,"Welcome Home!",$FE,$52 ]		'message
    
    HIGH motor
    pause 1000
    LOW motor
    pause 2000
    
    goto main

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Check the front section of your PBP manual for Code Crosses Page Boundary Messages for an explanation.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Jan 2009
    Location
    Miami, Florida USA
    Posts
    644


    Did you find this post helpful? Yes | No

    Default

    Also, in your PBP directory there is a file that lists all the posible error codes. I'm writing this post using my cellphone, so I can't tell you the name of the file.

    Robert

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rsocor01 View Post
    Also, in your PBP directory there is a file that lists all the posible error codes. I'm writing this post using my cellphone, so I can't tell you the name of the file.

    Robert
    PM.TXT is the file name.
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Apr 2010
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Thanks alot Bruce!

    I looked at the section, and that means it is not a memory overflow, just that certain codes were written in another page.

    But in the PBPro compiler, how do I find out where the "1st page" it was written in ends? PBP only has line numbers and therefore I wasnt able to figure out at which point in the code the program flipped to the next "page"

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    The compiler generates a .LST file. Open this and scroll down to 800h. You can see which code section crosses the page boundary.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts