blinking problem with PIC16f887


Results 1 to 6 of 6

Threaded View

  1. #4


    Did you find this post helpful? Yes | No

    Default the BLINKING led :)

    Hi larzazral

    Check what Joe said and read it all carefully and then check if you have an external oscillator (20 MHZ crystal).

    In the code below I have the defines setup and also ocsillator setting for the internal clock , code is commented as much as possible!

    Hope this helps

    Dennis

    Code:
    '*************************************
    'Blink and LED for 16F887 on PORTd.2
    '*************************************
    'Un-comment the lines below if you need to 
    '@__config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_ON & '_LVP_OFF & _CP_OFF
     
    'Ocsillator selections here
      'OSCCON = %01100001 for 4mhz, or OSCCON = %01110001for 8mhz
    '        OSCCON = %01110001           'Int CLK 8MHz
    '        ANSEL= %11111111       '$0F = disable A/D converter
    '        option_reg = 7     'switch pull-ups ON
    'END of oscillator selections
     
    'timer/oscillator defines 
    
    OSCCON = %01110001          'Int CLK 8MHz
    DEFINE OSC 8                '8MHz << NOTICE UPPERCASE ON DEFINE
    
    'END of timer/oscillator defines
    
    
    ANSEL = %00000000           'All digital
    OPTION_REG.7 = 0            'Weak pull-ups enabled
    
    
    
    'port clear 
    PORTA=0
    PORTB=0
    PORTC=0
    PORTD=0
    PORTE=0
    'end of port clear
    
    'Port IO directions and presets for port pins begin here
    'TRISX = %76543210   << TRIS bit order numbering
    'TRISA = %11111111    <<   'All pins are outputs
    '// Define port pins as inputs and outputs ...
            TRISA = %00000000 'all output
            TRISB = %00000000 'all output
            TRISC = %00000000 'all output
            TRISD = %00000000 'all output
            TRISE.0 = 0  'all output
            TRISE.1 = 0  'all output
            TRISE.2 = 0  'all output
    'End of Port IO directions and presets for port pins begin here
    
    'includes begin here
            INCLUDE "modedefs.bas"
           
    'end of includes
                       
    'variables begin here
            
    LED var PORTd.2   ' Alias PORTD.0 to LED
    
    'end of variables
    
    
    
    
        
    blinky: ' a program label called blinky
            high LED  ' LED on
            Pause 500       ' Delay for .5 seconds
    	low led  'LED off
            Pause 500       ' Delay for .5 seconds
          
               Goto blinky  ' Go back to blinky label and do it all over again
            End
    'End of all code
    Last edited by Dennis; - 25th January 2010 at 20:43.

Similar Threads

  1. Blinking an led problem on P16F84
    By aimenbukharie in forum General
    Replies: 1
    Last Post: - 20th March 2009, 05:00
  2. PIC16F887 Config problem
    By Agent36 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th November 2008, 22:38
  3. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  4. 7-segment display blinking problem?
    By serdar_ozcan in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th March 2006, 14:43
  5. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts