Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

mplab ASM not following calls properly

Status
Not open for further replies.

bitem2k

New Member
Please consider the following code:
Code:
INCLUDE "P16F627A.INC"
LIST P=16F627A


__Config _INTOSC_OSC_NOCLKOUT & _DATA_CP_OFF & _CP_OFF  &_LVP_OFF &_BOREN_ON    & _MCLRE_OFF    & _WDT_OFF & _PWRTE_OFF 

cblock    0x20
    SDelayCount    
endc

org 0
poweron


    BSF        STATUS,RP0     ;MOVE TO BANK1
    CLRF    TRISB        ;PORT B ALL OUTPUTS
    CLRF    TRISA        ;PORT a ALL OUTPUTS, EXCLUDING A5 OBVIOUSLY
    BCF        STATUS, RP0 ;MOVE TO BANK0

    CLRF    PORTA
    MOVLW 0x07 ;Turn comparators off and
    MOVWF CMCON ;enable pins for I/O

again
    MOVLW    0xff
    movwf    PORTA
    MOVLW    0
    MOVWF    PORTB

    [COLOR=Red]call     ShortDelay[/COLOR]
    
    MOVLW    0x00
    movwf    PORTA
    MOVLW    0
    MOVWF    PORTB
    call     ShortDelay
    
goto again


[B][COLOR=Red]ShortDelay [/COLOR]   [/B]    

[COLOR=Lime][B][COLOR=Green]MOVLW    H'40' [/COLOR][/B] [/COLOR]      ;Get current selected multiplex rate
        MOVWF    SDelayCount        ;Store desired delay count
[B][COLOR=Green]SDelayLoop[/COLOR][/B]

    NOP
        NOP
        NOP
        NOP
        DECFSZ    SDelayCount
        GOTO    SDelayLoop
        retlw    0


END

Im simulating in MPLAB.

For some reason when the ShortDelay is called
the PCL is set to the correct position(i.e MOVLW instruction), but the next time i press step into, the executing line skips to SDelayLoop.
if i press step into again, PCL Jumps away from my code to an undefined bit of memory (PCL reads Decimal:119).
My shortDelay code is never executed, and the microcontroller is no longer running any of my code!

Does anyone know whats happening here?

Many thanks:)
 
bitem2k said:
Does anyone know whats happening here?

I've just simulated your program and 'shortDelay' is executed as you would expect. It requires 453 cycles including 'call'.
So no, I don't know what's wrong with your simulation.
 
The only time I have seen this happen is when I have stepped through code that has been changed but not been recompiled.

Mike.
 
I believe that its somthing to do with an incompatability between mplab and vs.net 2005!

I shall email microchip.
 
I do alot of programming in C#, so im obviously running MPLAB and VS.net 2005 on the same machine (sometimes at the same time).

Im experiencing wierd problems trying to build tried and tested code in MPLAB.
If i re-install MPLAB, all the problems vanish until the next time I run VS.net.
Then I get build errors the next time I try and assemble code in MPlab.

I have just found a website that says

"
If you are running Visual Studio, then you may or may not know that Visual Studio appears to co-opt the file extension .cod. Apparently, Visual Studio doesn't play well with others, as it won't let other programs that need or use files having that extension...like MPLAB...use it for their own purposes.

* To the best of my observation, computers running Visual Studio will give linker errors when you attempt to build assembly files in MPLAB. The visible symptoms of the problem are error messages that refer to stack underflow or core errors. I will try to get specific error messages, so that you know what you're looking for to see if it's happened.
* The quickest solution (the one that was applied to best effect in the CEL) is to do a clean reinstall of MPLAB. This will make MPLAB work again, at least up to the point where you use Visual Studio to do something. Since no one uses Visual Studio in the CEL, we haven't had the chance to observe whether it attempts to grab the extension again.
* If you use Visual Studio often, you may find the MPLAB problem to be a recurring one. "
 
Nigel Goodwin said:
I may regret this?, but what's vs.net 2005 got to do with it?.

Its a MS application (a.k.a. virus) Nigel, it has everything to do with it.
 
Does setting the "Suppress Cod-file generation" in "Project>Build Options>project>MPLINK Linker" help.

Mike.
 
Pommie said:
Does setting the "Suppress Cod-file generation" in "Project>Build Options>project>MPLINK Linker" help.

Mike.
First thing I looked at!
It turns out that in the latest version, this flag is allready set by default.

Its so annoying! Stupid Micro$oft :mad::mad::mad:

Cant say that Microchip are being much help either.

Im going to try running two WINXP users at the same time and using the user switching functionallity of XP. One user will run VS.NET, the other MPLAB.

If it works, the only problem i will then have, is making sure I dont run VS.NET on the MPLAB user account:D

Cheers.
 
It would appear that my workaround works. Its definately easier than re-installing every 5 minutes.
 
Status
Not open for further replies.

Latest threads

Back
Top