PDA

View Full Version : Help me for get 5out put from 12f675



gihanasanka
- 13th August 2012, 16:40
Hi All


I wrote small project from assembly code for 12F675 . Now i need get 5 out put from it .

Hear is my code.....Please help me get 5output from 12F675 with speed controling by 100K preset.

Thanks

http://www.picbasic.co.uk/forum/images/icons/icon13.png



list p=12f675 ; list directive to define processor
#include <p12f675.inc> ; processor specific variable definitions
__CONFIG _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _CP_OFF & _CPD_ON
ERRORLEVEL -302
CBLOCK 0x020
Delay: 1 ; contor delay 100uS
Delay1: 1 ; contor delay 10mS
Delay2: 1 ; contor delay 1S
TEMP: 1 ; contor flash
ENDC
BANK0 MACRO ; MACRO DEFINITIONS ___ Selects register bank 0
BCF STATUS,RP0 ; clear bank select bits
ENDM
BANK1 MACRO ; Selects register bank 1
BSF STATUS,RP0 ;
ENDM
DISABLE_IRQ MACRO ; disable global irq
LOCAL STOP_INT
START_INT
BSF INTCON,GIE ; Enable global interrupt
BTFSS INTCON,GIE ; check if disabled
GOTO START_INT ; nope, try again
ENDM
ORG 0x000 ; processor reset vector
goto MAIN ; go to beginning of program
ORG 0x004 ; interrupt vector location
RETFIE ; return from interrupt
ORG 0x010; MAIN ROUTINE START HERE
MAIN:
Init_Prog:
BANK1 ; int osc calibration
call 0x3FF ; get the calibration value
movwf OSCCAL
BANK0
DISABLE_IRQ ; disable irqs / dezactivare intreruperi
call Init_Ports ; ports init / initializare portur
Prog_Loop:
BANK0


MOVLW B'00000001'
MOVWF GPIO
CALL DELAY
MOVLW B'00000010'
MOVWF GPIO
CALL DELAY
MOVLW B'00000100'
MOVWF GPIO
CALL DELAY
MOVLW B'00010000'
MOVWF GPIO
CALL DELAY
MOVLW B'00100000'
MOVWF GPIO
CALL DELAY
MOVLW B'00010000'
MOVWF GPIO
CALL DELAY
MOVLW B'00000100'
MOVWF GPIO
CALL DELAY
MOVLW B'00000010'
MOVWF GPIO
CALL DELAY

goto Prog_Loop
;;-------------------------------------
movlw 500
movwf Delay
DELAY
decfsz Delay,f
goto DELAY
decfsz Delay1,f
goto DELAY

;---------------------
Init_Ports:
BANK0 ; Bank 0
clrf GPIO ; 1)Status of pins: GPIO (GPIO=0 <ViL, =1 >ViH)
movlw B'00111111' ; 2)Comparator configuration
movwf CMCON ; Set GP<2:0> digital IO (comparator Off)
BANK1 ; Bank 1
bcf OPTION_REG,5 ; 3)TMR0 clock source select: Internal instruction cycle clock (CLKOUT)
bsf OPTION_REG,7 ; 4)GPIO pull-ups: is disabled
clrf WPU ; 5)Clear weak pull-up register
clrf IOC ; 6)Clear Interrupt-on-change register

movlw B'00000000' ; pins 3 & 4 are inputs and pins 2,5,6,7 are outputs
movwf TRISIO

; clrf ANSEL ; 8)* xxxx ANS<3..0> =0 digital I/O, =1 analog input
movlw b'00000000' ; pin 3 is analog,
movwf ANSEL




BANK0
return
org 3FFh
retlw 0x9C ;
;-----------------------------------------------------------------------------
END ; directive 'end of program'
;-----------------------------------------------------------------------------

AvionicsMaster1
- 13th August 2012, 19:49
Well, since no one else has said it, it appears your code is in assembly language. This being a BASIC forum is probably going to limit replies. If you have a BASIC program please post and maybe we can help. A schematic is useful information also.

Best wishes