Apparent code size problem


Closed Thread
Results 1 to 11 of 11

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Have you tried replacing your .asm initialization with a BASIC version?

    I know you can sometimes save a few bytes by doing some things in .asm,
    but if you initialize everything in banks PBP doesn't insert a ton of bank
    switching code flipping back & forth between banks. I.E.

    ' Bank0 first
    PORTB = 0
    PORTC = 0
    T2CON = 0
    ' Bank1 next
    TRISA = 0
    TRISB = 0
    CMCON1 = 7, etc, etc,

    Are you using assembler in other routines?

    I would think either something in the INI or Setup routines is causing
    the problem since the splash screen routine is supposed to run directly
    after Setup.

    If one routine is causing the problem, it should be easy to spot.

    Start:
    GOSUB INI
    blink an LED on return to here x times
    GOSUB Setup
    blink an LED on return to here x times, etc, etc,.

    Of course you could always run it through MPSIM too.
    Regards,

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

  2. #2
    Join Date
    Sep 2006
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Bruce,

    I tried the idea of replacing the asm routine with a basic one; pared the program down to just the ini and setup stuff and a display routine. Two versions, one all PBP and the other with the asm block.

    Now... I really feel stupid, the all basic one will not run, the other works just fine. So before I can actually try your idea I now have to figure out what I am doing wrong with the ini code in basic. ( and just in case everyone is wondering at this point... yes, I did write the asm block)

    I have included both below so that anyone who wants ( after they get up off the floor from laughing) can point out my mistake if they would.

    hope I got the code formatting command right so it is easy to read.

    Robert

    [code]
    '************************************************* ***************
    ' MCU Setup - inline assembly block *
    '************************************************* ***************
    INIMCU:
    asm
    bsf STATUS,RP0 ; Select Bank 1

    movlw 07h ; turn off comparators
    movwf CMCON0

    movlw 0xEC ; set A<5,1,0> as digital I/O
    movwf ANSEL ; A<3:2> and E<2:0> as analog

    movlw 0xFF ; set A<7:0> input; (A<3:2> analog; A<7:4,1:0> digital)
    movwf TRISA

    movlw 50h ; set A2D Clock 10h:Fosc/8 50h:Fosc/16
    movwf ADCON1

    movlw 00h ; set PORTB as outputs
    movwf TRISB

    movlw 0xF8 ; set PORTC C<7:3> as inputs; C<2:0> as outputs
    movwf TRISC

    movlw 0x00 ; set PORTD as inputs
    movwf TRISD

    movlw 0Fh ; set PORTE as inputs
    movwf TRISE

    bcf STATUS,RP0 ; Select Bank 2
    bsf STATUS,RP1 ;

    clrf LCDCON ; Disable VLCD<3:1>
    ; inputs on RC<2:0>

    bcf STATUS,RP0 ; Select Bank 0
    bcf STATUS,RP1
    endasm
    return



    '******************************
    ' MCU Setup - PBP
    '******************************
    INIMCU:
    CMCON0 = 7
    ANSEL = $EC
    TRISA = $FF
    ADCON1 = $50
    TRISB = 0
    TRISC = $F8
    TRISD = 0
    TRISE = $0F
    LCDCON = 0
    return

    [\code]

  3. #3
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    970


    Did you find this post helpful? Yes | No

    Default

    Robert

    I am wondering if you can do the following. Bruce already suggested this. I am just reminding you of the possibility (to catch a problem) of debugging this technique offers.

    Code:
    GOTO Start 
    
    INI:
    assembly block (with return) to setup the chip
    
    Setup:
    routine (with return) to set initial state of variables, etc
    
    Start:
       Led = 1:pause 1000:Led = 0
    GOSUB INI 
       Led = 1:pause 1000:Led = 0
    GOSUB Setup
       Led = 1:pause 1000:Led = 0
    
    Splash screen is displayed here.
    
    Some initail instrument checks ( proper hookup, etc) are performed here
    
    Switch polling routine here
    
    rest of code body
    if you see 3 flashes of the led, you have reached the splash screen code.

    Perhaps this will help you find if you are missing a return / stacking too deep. You may have a problem due to the limited caller stack size. Have you looked into this too?

    Jerson

Similar Threads

  1. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 9th December 2008, 00:40
  2. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 09:26
  3. problem with my code
    By civicgundam in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 3rd February 2008, 02:52
  4. Setting code size boundaries
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th March 2007, 21:11
  5. Servo Code problem
    By ALFRED in forum General
    Replies: 1
    Last Post: - 2nd March 2006, 04:30

Members who have read this thread : 0

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