DISCONTINUED!

Recommended replacement: SIGMA with software INSIDER



ASIX Home

INSIDER - Examples

   >>> Home 2003-12-06  

There are three examples available:

PIC Example: Using MACRO

; EXAMPLE 1: macro INSIDER UserReg

; This macro sends UserReg register contents to INSIDER's display.
; UserReg contents remains unchanged; no other register is required,
; W is unused, no stack level is necessary.
; 40 instructions and 40 instruction cycles are required.

; INSIDER setup (DIP switch positions):
;  * CP = 0 (falling edge)
;  * EU = 0 (enable unused)
;  * EF = 0 (enable = clock enable)
;  * EP = 0 (enable active low)

;-----------------------------------------------------------------------
;       HARDWARE DEFINITION
        list        F=INHX8M, P=16F84A, R=HEX  ; compiler directives
        __config    0x3FFB                     ; configuration word

;-----------------------------------------------------------------------
; User Pins (Tris: 0x3F)
#define     ICLK    PORTB,7 ; INSIDER clock
#define     IDATA   PORTB,6 ; INSIDER data

; Special Function Registers
INDF        equ     00h    
TMR0        equ     01h     ; bank 0
ROPTION     equ     01h     ; bank 1
PCL         equ     02h     
STATUS      equ     03h     
FSR         equ     04h     
PORTA       equ     05h     ; bank 0
PORTB       equ     06h     ; bank 0
TRISA       equ     05h     ; bank 1
TRISB       equ     06h     ; bank 1

#define ZERO    STATUS,2    ; Zero flag
#define DC      STATUS,1    ; DC flag
#define CARRY   STATUS,0    ; C flag

; User registers
UserReg1     equ         0x0C   
UserReg2     equ         0x0D   

;-----------------------------------------------------------------------
; macro definition
Insider macro   OutReg
        bcf     IDATA       ; bit 7
        btfsc   OutReg, 7
        bsf     IDATA
        bsf     ICLK
        bcf     ICLK
        
        bcf     IDATA       ; bit 6
        btfsc   OutReg, 6
        bsf     IDATA
        bsf     ICLK
        bcf     ICLK
        
        bcf     IDATA       ; bit 5
        btfsc   OutReg, 5
        bsf     IDATA
        bsf     ICLK
        bcf     ICLK
        
        bcf     IDATA       ; bit 4
        btfsc   OutReg, 4
        bsf     IDATA
        bsf     ICLK
        bcf     ICLK
        
        bcf     IDATA       ; bit 3
        btfsc   OutReg, 3
        bsf     IDATA
        bsf     ICLK
        bcf     ICLK
        
        bcf     IDATA       ; bit 2
        btfsc   OutReg, 2
        bsf     IDATA
        bsf     ICLK
        bcf     ICLK
        
        bcf     IDATA       ; bit 1
        btfsc   OutReg, 1
        bsf     IDATA
        bsf     ICLK
        bcf     ICLK
        
        bcf     IDATA       ; bit 0
        btfsc   OutReg, 0
        bsf     IDATA
        bsf     ICLK
        bcf     ICLK
        endm

Bnk0    macro               ; set bank 0 
        bcf     STATUS,5
        endm
        
Bnk1    macro               ; set bank 1
        bsf     STATUS,5
        endm
        
;-----------------------------------------------------------------------
        org     0x00
        goto    Start       ; 1st instruction - jump to program start

        org     0x10        ; program start
Start:  Bnk1
        movlw   0x3F
        movwf   TRISB       ; set-up port B direction
        Bnk0                ; (INSIDER pins RB6 and RB7 are outputs)
        clrf    PORTB       ; set log.0 levels on INSIDER pins

        movlw   0x1A
        movwf   UserReg1    ; put data to UserReg1
        movlw   0x3F
        movwf   UserReg2    ; put data to UserReg2

        nop
        nop                 ; ...user's code

        Insider UserReg1    ; show UserReg1 value on INSIDER's display

        nop
        nop                 ; ...user's code

        Insider UserReg2    ; show UserReg2 value on INSIDER's display

        nop
        nop                 ; ...user's code
        
Stop:   goto Stop
        end

PIC Example: Using CALL

; EXAMPLE 2: call INSIDER, W=parameter

; This subroutine sends W register contents to INSIDER's display.
; One user register (IReg) and one stack level is required.
; W register contents remains unchanged.
; 20 instructions are required.

; INSIDER setup (DIP switch positions):
;  * CP = 0 (falling edge)
;  * EU = 0 (enable unused)
;  * EF = 0 (enable = clock enable)
;  * EP = 0 (enable active low)

;-----------------------------------------------------------------------
;       HARDWARE DEFINITION
        list        F=INHX8M, P=16F84A, R=HEX  ; compiler directives
        __config    0x3FFB                     ; configuration word

;-----------------------------------------------------------------------
; User Pins (Tris: 0x3F)
#define     ICLK    PORTB,7 ; INSIDER clock
#define     IDATA   PORTB,6 ; INSIDER data

; Special Function Registers
INDF        equ     00h    
TMR0        equ     01h     ; bank 0
ROPTION     equ     01h     ; bank 1
PCL         equ     02h     
STATUS      equ     03h     
FSR         equ     04h     
PORTA       equ     05h     ; bank 0
PORTB       equ     06h     ; bank 0
TRISA       equ     05h     ; bank 1
TRISB       equ     06h     ; bank 1

#define ZERO    STATUS,2    ; Zero flag
#define DC      STATUS,1    ; DC flag
#define CARRY   STATUS,0    ; C flag

; INSIDER auxiliary register
IReg    equ         0x0C   ; pracovni registr Insideru

; User register
UserReg equ         0x0D

;-----------------------------------------------------------------------
Bnk0    macro               ; set bank 0 
        bcf     STATUS,5
        endm
        
Bnk1    macro               ; set bank 1
        bsf     STATUS,5
        endm

;-----------------------------------------------------------------------
; Startup
        org     0x00
        goto    Start       ; 1st instruction - jump to program start

;-----------------------------------------------------------------------
; INSIDER procedure       
        org     0x05        
Insider:movwf   IReg        ; save W to IReg
        movlw   0x08        ; preset cycle length
ICykl:  rlf     IReg,f
        bcf     IDATA
        btfsc   CARRY       ; set pin IDATA
        bsf     IDATA
        bsf     ICLK        
        bcf     ICLK        ; falling edge writes bit to INSIDER

        btfss   CARRY       ; check CARRY bit state
        goto    Ic0         ; CARRY is 0
        addlw   -1          ; CARRY was 1, W=W-1
        bsf     CARRY       ; restore CARRY state
Istop:  btfss   ZERO
        goto    Icykl       ; repeat 8 times

        rlf     IReg,f      ; restore IReg register
        movf    IReg,w      ; restore W register
        return
Ic0:    addlw   -1          ; CARRY was 0, W=W-1
        bcf     CARRY       ; restore CARRY state
        goto    Istop

;-----------------------------------------------------------------------
Start:  Bnk1
        movlw   0x3F
        movwf   TRISB       ; set-up port B direction
        Bnk0                ; (INSIDER pins RB6 and RB7 are outputs)
        clrf    PORTB       ; set log.0 levels on INSIDER pins

        nop
        nop                 ; ...user's code

        movlw   0x1A
        call    Insider     ; show W value on INSIDER's display

        nop
        nop                 ; ...user's code

        movlw   0xA6        ; put data to UserReg
        movwf   UserReg
                            ; ...
                            
        movf    UserReg,w   ; read UserReg
        call    Insider     ; show UserReg value on INSIDER's display
        
        nop
        nop                 ; ...user's code
        
Stop:   goto Stop
        end

FPGA Xilinx Example Schematics

FPGA - EXAMPLE: block sends data to INSIDER in 2-wire mode

INSIDER setup (DIP switch positions):

  • CP = 0 (falling edge)
  • EU = 0 (enable unused)
  • EF = 0 (enable = clock enable)
  • EP = 0 (enable active low)
FPGA example


© ASIX s.r.o., 1991-2003. All rights reserved.