assemblycode in Flowcode

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 2 and 3.

Moderators: Benj, Mods

Post Reply
Andi
Posts: 19
Joined: Thu Nov 29, 2007 12:08 pm
Contact:

assemblycode in Flowcode

Post by Andi »

hi, i tryed to implement an assembly code in my flowcode programm, but just "movlw" is working
if i try "movwf", "andwf" or "btfss" flowcode creates an error...
What do i do wrong?
(i use flowcode student version)

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: assemblycode in Flowcode

Post by Benj »

Hello

Please could you post the piece of code you are using and the error message associated with it.

You should be able to use assembler statements like this

asm{

commands

}

Also isnt movwf actually movf, I think the same goes for the andwf which is actually andf.

Im not great on assembler so I could be wrong.

Andi
Posts: 19
Joined: Thu Nov 29, 2007 12:08 pm
Contact:

Re: assemblycode in Flowcode

Post by Andi »

with my assembler programm, i whould use the LVD (Low Voltage Detect) Funktion
in MPLAB, it works, but when i try to use the same code in flowcode it does not work... here is my assembler code i try to use (this code works in MPLAP):

//with these lines, i initialise the LVD trip point
MOVLW 0x1B ; Enable LVD, Trip point = 3,4V
MOVWF LVDCON ;
//now i check the interrupt flag
LVD_STABLE:
BTFSS LVDCON, IRVST ; Has LVD circuitry stabilized? if there is no interruptflag is set, stay in loop, else ignore the following command (GOTO LVD_STABLE)
GOTO LVD_STABLE ; NO, Wait longer

//Interrupt flag is set
BCF PIR2, LVDIF ; YES, clear LVD interrupt flag
BSF PIE2, LVDIE ; Enable LVD interrupt
BSF STATUS,5 ;Go to Bank 1
MOVLW 00h ;Put 00000 into W
MOVWF TRISA ;Move 00000 onto TRISA – all pins set to output
BCF STATUS,5 ;Come back to Bank 0

//the interrupt flag is set, and now i put out "1" on RA0
CLRF PORTA
CLRF LATA
MOVLW 0x7F
MOVWF ADCON1
MOVLW 0xFE
ANDWF TRISA, W
MOVWF TRISA
MOVLW 0xFE
ANDWF PORTA, W
MOVWF CompTempVar605
MOVLW 0x01
IORWF CompTempVar605, W
MOVWF PORTA
END


here is the same code, modified for Flowcode, where no command works and creates errors:

asm
{
MOVLW 0x1B ; Enable LVD, Trip point = 3,4V
MOVWF gbl_lvdcon ;
//now i check the interrupt flag
LVD_STABLE:
BTFSS gbl_lvdcon, IRVST ; Has LVD circuitry stabilized? if there is no interruptflag is set, stay in loop, else ignore the following command (GOTO LVD_STABLE)
GOTO LVD_STABLE ; NO, Wait longer

//Interrupt flag is set
BCF gbl_pir2, LVDIF ; YES, clear LVD interrupt flag
BSF gbl_pie2, LVDIE ; Enable LVD interrupt
BSF STATUS,5 ;Go to Bank 1
MOVLW 00h ;Put 00000 into W
MOVWF gbl_trisa ;Move 00000 onto TRISA – all pins set to output
BCF STATUS,5 ;Come back to Bank 0

//the interrupt flag is set, and now i put out "1" on RA0
CLRF gbl_porta
CLRF gbl_lata
MOVLW 0x7F
MOVWF gbl_adcon1
MOVLW 0xFE
ANDWF gbl_trisa, W
MOVWF gbl_trisa
MOVLW 0xFE
ANDWF gbl_porta, W
MOVWF CompTempVar605
MOVLW 0x01
IORWF CompTempVar605, W
MOVWF gbl_porta
END
}

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: assemblycode in Flowcode

Post by Benj »

Hello

Please could you tell me which PICmicro you are using that has the LVDCON register.

Andi
Posts: 19
Joined: Thu Nov 29, 2007 12:08 pm
Contact:

Re: assemblycode in Flowcode

Post by Andi »

PIC18F1320

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: assemblycode in Flowcode

Post by Benj »

Hello

The code is now compiling corrently. Please refer to the BoostC manual located in the Flowcode V3/BoostC folder for further help with porting code to BoostC.

Code: Select all

char CompTempVar605 = 0;

asm
{
MOVLW 0x1B ; Enable LVD, Trip point = 3,4V
MOVWF _lvdcon ;
//now i check the interrupt flag
LVD_STABLE:
BTFSS _lvdcon, IRVST ; Has LVD circuitry stabilized? if there is no interruptflag is set, stay in loop, else ignore the following command (GOTO LVD_STABLE)
GOTO LVD_STABLE ; NO, Wait longer

//Interrupt flag is set
BCF _pir2, LVDIF ; YES, clear LVD interrupt flag
BSF _pie2, LVDIE ; Enable LVD interrupt
BSF _status,5 ;Go to Bank 1
MOVLW 00h ;Put 00000 into W
MOVWF _trisa ;Move 00000 onto TRISA – all pins set to output
BCF _status,5 ;Come back to Bank 0

//the interrupt flag is set, and now i put out "1" on RA0
CLRF _porta
CLRF _lata
MOVLW 0x7F
MOVWF _adcon1
MOVLW 0xFE
ANDWF _trisa, W
MOVWF _trisa
MOVLW 0xFE
ANDWF _porta, W
MOVWF _CompTempVar605
MOVLW 0x01
IORWF _CompTempVar605, W
MOVWF _porta
}

Andi
Posts: 19
Joined: Thu Nov 29, 2007 12:08 pm
Contact:

Re: assemblycode in Flowcode

Post by Andi »

juhuuu :)
now it works!

very big thanks!!!

Post Reply