erratic behavior when using MPASM vs. PM


Closed Thread
Results 1 to 7 of 7
  1. #1

    Unhappy erratic behavior when using MPASM vs. PM

    Hi,

    I've been programming with PBP 2.42 for a while now, but have never had a problem that I couldn't overcome by reading the forums.

    Recently, I tried to get Darrel Taylor's great Instant Interrupt program running. I installed MPASM, no problems there. The blink LED program worked great.

    In order to incorporate the instant interrupt functionality back into my main code, I had to get that code assembling with MPASM (versus PM) first. I read all about the configuration fuses and am fairly sure I have them set correctly. The code compiles and loads (via MCS loader) into my 16F877a without any issues (the only warnings are the 'page boundary' warnings, which I ignore). However, the code runs very erratically now. The LCDOUT commands don't work, and the timing on my GPIO seems to be much faster.

    After playing around with the configuration fuses, they don't seem to change anything. In fact, I can comment them out of my main code (and the 16F877a.inc file) and get the same erratic results.

    I went back to Darrel's Interrupt program just to see if I could get my 16x1 LCD working there...no go.

    In conclusion, I believe if someone can tell me why the code below doesn't work with my LCD, I will be able to figure out why it doesn't work in my main program. The portb.1 does toggle (as intended), but I get nothing on my LCD. The hardware is connected correctly as the LCD works with my main code compiled with PM. This program is basically Darrel Taylor's blinky program, but with an LCDOUT after the LCD toggle.

    Thanks in advance for the help - there are so many talented people who contribute to this forum and I appreciate your time!


    LED1 VAR PORTB.1

    define osc 20 'using 20 MHz crystal
    define loader_used 1 'using a loader...
    define lcd_dreg portb 'set LCD data port
    define lcd_dbit 4 'set LCD starting Data bit = 4 (portd.4-7)
    DEFINE lcd_rsreg portb 'set LCD register select port
    define lcd_rsbit 2 'set LCD register select bit
    define lcd_ereg portb 'set LCD enable port
    define lcd_egreg 3 'set LCD enable bit
    define lcd_bits 4 'set LCD bus size (4 or 8 bits)
    define lcd_lines 2 'set number of lines on LCD
    define lcd_commandus 2000 'set command delay time in us
    define lcd_dataus 50 'set data delay time in us

    INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts

    ASM
    INT_LIST macro ; IntSource, Label, Type, ResetFlag?
    INT_Handler TMR1_INT, _ToggleLED1, PBP, yes
    endm
    INT_CREATE ; Creates the interrupt processor
    ENDASM

    T1CON = $31 ; Prescaler = 8, TMR1ON
    @ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts

    Main:
    PAUSE 1
    GOTO Main

    '---[TMR1 - interrupt handler]--------------------------------------------------
    ToggleLED1:
    TOGGLE LED1
    lcdout $FE, $80, "Hi World"
    pause 1000
    @ INT_RETURN

    \code

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


    Did you find this post helpful? Yes | No

    Default

    Change define lcd_egreg 3 to DEFINE LCD_EBIT 3
    Last edited by Bruce; - 7th June 2006 at 12:34.
    Regards,

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

  3. #3


    Did you find this post helpful? Yes | No

    Default more information

    Bruce,
    Thanks for the suggestion. I changed egreg to ebit in my code, and still no luck.

    I took the code posted above, commented out the interrupt portion and moved the LCDOUT command to the main loop (since there's no more interrupt), compiled with PM, and no issues. "Hi World" is displayed on my LCD.

    After reading the threads by Melanie and others, my understanding is the only difference in assembling between PM and MPASM is the configuration fuses. However, all the combinations of configuration fuses I've tried does not yield good results. Again, the code compiles, assembled, and loads, but no LCDOUT and timing is erratic...

    This code is so small, I know there's got to be a fairly simple answer to this issue, I just can't figure it out...

    Here is the code that compiled and worked great with PM:




    LED1 VAR PORTB.1

    define osc 20 'using 20 MHz crystal
    define loader_used 1 'using a loader
    define lcd_dreg portb 'set LCD data port
    define lcd_dbit 4 'set LCD starting Data bit
    DEFINE lcd_rsreg portb 'set LCD register select port
    define lcd_rsbit 2 'set LCD register select bit
    define lcd_ereg portb 'set LCD enable port
    'define lcd_egreg 3 'set LCD enable bit
    DEFINE LCD_EBIT 3
    define lcd_bits 4 'set LCD bus size (4 or 8 bits)
    define lcd_lines 2 'set number of lines on LCD
    define lcd_commandus 2000 'set command delay time in us
    define lcd_dataus 50 'set data delay time in us

    'INCLUDE "DT_INTS-14.bas" ' Base Interrupt System
    'INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts
    '
    'ASM
    'INT_LIST macro ; IntSource, Label, Type, ResetFlag?
    ' INT_Handler TMR1_INT, _ToggleLED1, PBP, yes
    ' endm
    ' INT_CREATE ; Creates the interrupt processor
    'ENDASM

    'T1CON = $31 ; Prescaler = 8, TMR1ON
    '@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts

    Main:
    lcdout $FE, $80, "Hi World"
    PAUSE 1
    GOTO Main

    '---[TMR1 - interrupt handler]--------------------------------------------------
    'ToggleLED1:
    ' TOGGLE LED1
    ' lcdout $FE, $80, "Hi World"
    ' pause 1000
    '@ INT_RETURN

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Miip.. forget me... i was wrong... i'll read the whole stuff later and i'll be back
    Last edited by mister_e; - 7th June 2006 at 23:01.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Default

    Are you loading your code via a boot-loader? If you are, then config fuse
    settings embedded in your compiled file shouldn't matter. Config fuses are
    fixed in the loader firmware.

    If you're programming it in your device programmer, then make sure your
    config fuse settings are the same from one version to the next before burning.
    Regards,

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

  6. #6


    Did you find this post helpful? Yes | No

    Thumbs up solution found!

    Thanks Bruce for your suggestions!

    I looked again at Darrel Taylor's instant interrupt program (elapsed timer) and tried to look at the differences between code.

    It turns out that MPASM was set as 'case sensitive' under MCS view-> PIC Basic Options -> Assembler.

    Not all of my define statements were in all caps and apparently something didn't like that. Anyhow, after turning 'case sensitive' to OFF, everything works great!

    It did give me one warning I hadn't seen before, though:
    "pbppic14.lib 3382:Argument out of range. Least significant bits used."

    This sounds disturbing - like it is truncating a variable or something somewhere. Is this anything I should be concerned with? Anyone see it before?

    Thanks!!
    Justin

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


    Did you find this post helpful? Yes | No

    Default

    Hi Justin,

    Open pbppic14.lib and scroll down to line 3382 to see what that section of
    the PBP library is. It's different in V2.46. The library has grown a good deal
    since V2.42.
    Regards,

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

Similar Threads

  1. Presetting Configuration Fuses (PIC Defines) into your Program
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 82
    Last Post: - 15th December 2013, 09:54
  2. Moved from PM to MPASM and have fuse definition problems
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 26th November 2008, 22:27
  3. MPASM vs PM
    By Squibcakes in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th October 2007, 01:29
  4. Converting to MPASM
    By btaylor in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 4th November 2005, 01:35
  5. PM assembler versus MPAsm
    By bwarb in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 16th August 2005, 16:14

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