CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

pic16f88 LED flasher

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
indep



Joined: 30 Mar 2011
Posts: 8
Location: 840

View user's profile Send private message

pic16f88 LED flasher
PostPosted: Fri Apr 01, 2011 7:25 am     Reply with quote

hello dear friends

is there anyone can give me sch and assembly code for a simple LED flasher using pic16f88 Smile many thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 01, 2011 1:05 pm     Reply with quote

Here is a 16F88 program to flash an LED:
http://www.ccsinfo.com/forum/viewtopic.php?t=34839&start=3

Here is a schematic. Note that the cathode of the LED must connect
to ground:
Code:

pin      330 ohms      LED       
A1    ---/\/\/\/------->|----
                            |
                            |
                          -----  Ground 
                           ---
                            -
indep



Joined: 30 Mar 2011
Posts: 8
Location: 840

View user's profile Send private message

hello PCM
PostPosted: Tue Apr 05, 2011 7:51 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 05, 2011 8:01 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 05, 2011 8:09 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 05, 2011 8:34 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Apr 05, 2011 8:38 am     Reply with quote

where could i find the manual?! thanks.. Smile
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Tue Apr 05, 2011 8:54 am     Reply with quote

The CCS C manual can be found here:

http://www.ccsinfo.com/downloads.php
_________________
Google and Forum Search are some of your best tools!!!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group