Hi again
This what the Flowcode compiles to in C and asm using one of the examples provided with the software.
//************************************************************************************
#define MX_PIC
//Defines for microcontroller
#define P16F628A
#define MX_EE
#define MX_EE_TYPE1
#define MX_EE_SIZE 128
#define MX_UART
#define MX_UART_B
#define MX_UART_TX 2
#define MX_UART_RX 1
#define MX_PWM
#define MX_PWM_CNT 1
#define MX_PWM_TRIS1 trisb
#define MX_PWM_1 3
//Functions
#include <system.h>
#pragma CLOCK_FREQ 19660800
//Configuration data
//Internal functions
#include "C:\Program Files\Matrix Multimedia\Flowcode V3\FCD\internals.h"
//Macro function declarations
void FCM_INTERRUPT_TMR0();
void FCM_INTERRUPT_RB0INT();
void FCM_INTERRUPT_PORTB();
//Variable declarations
char FCV_SWITCHES;
short FCV_SWITCH;
char FCV_HOLD;
//Supplementary defines
//Macro implementations
void FCM_INTERRUPT_TMR0()
{
}
void FCM_INTERRUPT_RB0INT()
{
}
void FCM_INTERRUPT_PORTB()
{
}
//Supplementary implementations
void main()
{
//Input from switches
//Initialisation
cmcon = 0x07;
//Interrupt initialisation code
option_reg = 0xC0;
//Infinite Loop
//Loop: While 1
while (1)
{
//Get input from switches on Port A
//Input: PORT A -> SWITCHES
trisa = trisa | 0xff;
FCV_SWITCHES = porta;
//Send switch data to the LEDs on Port B
//Output: SWITCHES -> PORT B
trisb = 0x00;
portb = FCV_SWITCHES;
}
mainendloop: goto mainendloop;
}
void interrupt(void)
{
}
And in asm:
include "P16F628A.inc"
; Heap block 0, size:95 (0x000000A0 - 0x000000FE)
__HEAP_BLOCK0_BANK EQU 0x00000001
__HEAP_BLOCK0_START_OFFSET EQU 0x00000020
__HEAP_BLOCK0_END_OFFSET EQU 0x0000007E
; Heap block 1, size:76 (0x00000024 - 0x0000006F)
__HEAP_BLOCK1_BANK EQU 0x00000000
__HEAP_BLOCK1_START_OFFSET EQU 0x00000024
__HEAP_BLOCK1_END_OFFSET EQU 0x0000006F
; Heap block 2, size:48 (0x00000120 - 0x0000014F)
__HEAP_BLOCK2_BANK EQU 0x00000002
__HEAP_BLOCK2_START_OFFSET EQU 0x00000020
__HEAP_BLOCK2_END_OFFSET EQU 0x0000004F
; Heap block 3, size:0 (0x00000000 - 0x00000000)
__HEAP_BLOCK3_BANK EQU 0x00000000
__HEAP_BLOCK3_START_OFFSET EQU 0x00000000
__HEAP_BLOCK3_END_OFFSET EQU 0x00000000
gbl_status EQU 0x00000003 ; bytes:1
gbl_indf EQU 0x00000000 ; bytes:1
gbl_tmr0 EQU 0x00000001 ; bytes:1
gbl_pcl EQU 0x00000002 ; bytes:1
gbl_fsr EQU 0x00000004 ; bytes:1
gbl_porta EQU 0x00000005 ; bytes:1
gbl_portb EQU 0x00000006 ; bytes:1
gbl_pclath EQU 0x0000000A ; bytes:1
gbl_intcon EQU 0x0000000B ; bytes:1
gbl_pir1 EQU 0x0000000C ; bytes:1
gbl_tmr1l EQU 0x0000000E ; bytes:1
gbl_tmr1h EQU 0x0000000F ; bytes:1
gbl_t1con EQU 0x00000010 ; bytes:1
gbl_tmr2 EQU 0x00000011 ; bytes:1
gbl_t2con EQU 0x00000012 ; bytes:1
gbl_ccpr1l EQU 0x00000015 ; bytes:1
gbl_ccpr1h EQU 0x00000016 ; bytes:1
gbl_ccp1con EQU 0x00000017 ; bytes:1
gbl_rcsta EQU 0x00000018 ; bytes:1
gbl_txreg EQU 0x00000019 ; bytes:1
gbl_rcreg EQU 0x0000001A ; bytes:1
gbl_cmcon EQU 0x0000001F ; bytes:1
gbl_option_reg EQU 0x00000081 ; bytes:1
gbl_trisa EQU 0x00000085 ; bytes:1
gbl_trisb EQU 0x00000086 ; bytes:1
gbl_pie1 EQU 0x0000008C ; bytes:1
gbl_pcon EQU 0x0000008E ; bytes:1
gbl_pr2 EQU 0x00000092 ; bytes:1
gbl_txsta EQU 0x00000098 ; bytes:1
gbl_spbrg EQU 0x00000099 ; bytes:1
gbl_eedata EQU 0x0000009A ; bytes:1
gbl_eeadr EQU 0x0000009B ; bytes:1
gbl_eecon1 EQU 0x0000009C ; bytes:1
gbl_eecon2 EQU 0x0000009D ; bytes:1
gbl_vrcon EQU 0x0000009F ; bytes:1
gbl_FCV_SWITCHES EQU 0x00000023 ; bytes:1
Int1Context EQU 0x0000007F ; bytes:1
Int1BContext EQU 0x00000020 ; bytes:3
ORG 0x00000000
GOTO _startup
ORG 0x00000004
MOVWF Int1Context
SWAPF STATUS, W
BCF STATUS, RP0
BCF STATUS, RP1
MOVWF Int1BContext
SWAPF PCLATH, W
MOVWF Int1BContext+D'1'
SWAPF FSR, W
MOVWF Int1BContext+D'2'
BCF PCLATH,3
BCF PCLATH,4
GOTO interrupt
ORG 0x00000010
main
; { main ; function begin
MOVLW 0x07
BCF STATUS, RP0
BCF STATUS, RP1
MOVWF gbl_cmcon
MOVLW 0xC0
BSF STATUS, RP0
MOVWF gbl_option_reg
label268439634
MOVLW 0xFF
BSF STATUS, RP0
IORWF gbl_trisa, W
MOVWF gbl_trisa
BCF STATUS, RP0
MOVF gbl_porta, W
MOVWF gbl_FCV_SWITCHES
BSF STATUS, RP0
CLRF gbl_trisb
BCF STATUS, RP0
MOVF gbl_FCV_SWITCHES, W
MOVWF gbl_portb
GOTO label268439634
; } main function end
ORG 0x00000024
_startup
BCF PCLATH,3
BCF PCLATH,4
GOTO main
ORG 0x00000027
interrupt
; { interrupt ; function begin
BCF STATUS, RP0
BCF STATUS, RP1
SWAPF Int1BContext+D'2', W
MOVWF FSR
SWAPF Int1BContext+D'1', W
MOVWF PCLATH
SWAPF Int1BContext, W
MOVWF STATUS
SWAPF Int1Context, F
SWAPF Int1Context, W
RETFIE
; } interrupt function end
END
The example turns the LED's on using push to make switches but does not latch.
I hope this helps the board understand what I'm after.
cheers
Gaz