View previous topic :: View next topic |
Author |
Message |
indep
Joined: 30 Mar 2011 Posts: 8 Location: 840
|
pic16f88 LED flasher |
Posted: Fri Apr 01, 2011 7:25 am |
|
|
hello dear friends
is there anyone can give me sch and assembly code for a simple LED flasher using pic16f88 many thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
indep
Joined: 30 Mar 2011 Posts: 8 Location: 840
|
hello PCM |
Posted: Tue Apr 05, 2011 7:51 am |
|
|
i have my basic assembly code for LED FLASHER
but when i am trying to compile it using MPLAB,
i am getting an error in the __CONFIG part is says
Error[126] F:\RALPH\FLASHER.ASM 33 : Argument out of range (not a valid config register address)
here my code:
Code: | ; HEAD88.ASM for 16F88. This sets PORTA as digital INPUT. PORTB is an OUTPUT.
;Internal oscillator of 31.25kHz chosen
; The OPTION register is set to /256 to give timing pulses of 32.768ms with 31.25kHz crystal.
; 1second and 0.5 second delays are included in the subroutine section.
;*********************************************************
; EQUATES SECTION
TMR0 EQU 1 ;means TMR0 is file 1.
STATUS EQU 3 ;means STATUS is file 3.
PORTA EQU 5 ;means PORTA is file 5.
PORTB EQU 6 ;means PORTB is file 6.
ZEROBIT EQU 2 ;means ZEROBIT is bit 2.
ADCON0 EQU 1FH ;A/D Configuration reg.0
ANSEL EQU 9BH
ADRES EQU 1EH ;A/D Result register.
CARRY EQU 0 ;CARRY IS BIT 0.
TRISA EQU 85H
TRISB EQU 86H
OPTION_R EQU 81H
OSCCON EQU 8FH ;Oscillator control register.
COUNT EQU 20H ;means COUNT is file 20H, a register to count events.
;*********************************************************
LIST P=16F88 ;we are using the 16F818.
ORG 0 ;the start address in memory is 0
GOTO START ;goto start!
;*********************************************************
; Configuration Bits
__config H'3F10' ;sets INTRC-A6 is port I/O, WDT off, PUT on, MCLR tied to VDD A5 is I/O
;BOD off, LVP disabled, EE protect disabled, Flash Program Write disabled,
;Background Debugger Mode disabled, CCP function on B2, Code Protection ;disabled.
;*****************************************************
;SUBROUTINE SECTION.
; 0.1 second delay, actually 0.099968s
DELAYP1 CLRF TMR0 ;START TMR0.
LOOPB MOVF TMR0,W ;READ TMR0 INTO W.
SUBLW .3 ;TIME - 3
BTFSS STATUS,ZEROBIT ; Check TIME-W = 0
GOTO LOOPB ;Time is not = 3.
NOP ;add extra delay
NOP
RETLW 0 ;Time is 3, return.
; 0.5 second delay.
DELAYP5 MOVLW .5
MOVWF COUNT
LOOPC CALL DELAYP1
DECFSZ COUNT
GOTO LOOPC
RETLW 0
; 1 second delay.
DELAY1 MOVLW .10
MOVWF COUNT
LOOPA CALL DELAYP1
DECFSZ COUNT
GOTO LOOPA
RETLW 0
;*********************************************************
;Configuration Section
START BSF STATUS,5 ;Turns to Bank1.
MOVLW B'11111111' ;PORTA is I/P
MOVWF TRISA
MOVLW 0 ;PORTA IS DIGITAL
MOVWF ANSEL
MOVLW B'00000000'
MOVWF TRISB ;PORTB is OUTPUT
MOVLW B'00000000'
MOVWF OSCCON ;oscillator 31.25kHz
MOVLW B'00000111' ;Prescaler is /256
MOVWF OPTION_R ;TIMER is 1/32 secs.
BCF STATUS,5 ;Return to Bank0.
CLRF PORTA ;Clears PortA.
CLRF PORTB ;Clears PortB.
;*********************************************************
;Program starts now.
BEGIN BSF PORTB,0 ;Turn ON B0.
CALL DELAYP5 ;Wait 0.5 seconds
BCF PORTB,0 ;Turn OFF B0.
CALL DELAYP5 ;Wait 0.5 seconds
GOTO BEGIN ;Repeat
END ;YOU MUST END!!
|
|
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Tue Apr 05, 2011 8:01 am |
|
|
You are in the wrong place... This is not an assembly code forum. It is the
CCS C code forum.
The Microchip forums are located here:
http://www.microchip.com/forums/Default.aspx? _________________ Google and Forum Search are some of your best tools!!!! |
|
|
indep
Joined: 30 Mar 2011 Posts: 8 Location: 840
|
|
Posted: Tue Apr 05, 2011 8:09 am |
|
|
ohh okay.. still if you put that __CONFIG in C its still having error..
Also i wanted to know how can you put your assembly in C code? Because in my other project in assembly code as well i have a digital value and i need to convert it to voltage again, it is awkward to do dividing in assembly, can you put .asm file to C then do the dividing through C?? thanks |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Tue Apr 05, 2011 8:34 am |
|
|
Yes, you can easily 'insert' assembly into CCS C by using the preprocessor directives #asm, #endasm. Either download the manual or press F11 in an open project to read about it. |
|
|
indep
Joined: 30 Mar 2011 Posts: 8 Location: 840
|
|
Posted: Tue Apr 05, 2011 8:38 am |
|
|
where could i find the manual?! thanks.. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
|
|