PIC16F1825 unable to Light an LED


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2012
    Location
    Leicester UK
    Posts
    21

    Default PIC16F1825 unable to Light an LED

    Hello

    I can't seem to find a reason why I am struggling to light an LED tied to Pin 2 (MCE, PORTA.5) of a PIC16F1825.

    I have checked the polarity of the LED and also changed it out for LEDs that are working, the resistor is also functioning correctly. When the pin goes high then the LED should light.

    Can anybody see a reason why this LED doesn't light?

    I am wondering if it's a case of not being able to see the wood for the trees and it is actually something very simple.

    Code:
    clear
    DEFINE OSC 32
    
    'PINS 
    Current_Pos_In VAR PORTA.4      'RA4    AN3   Pot input for current position
    MCE VAR PORTA.5                 'RA5    OUT   Enable H Bridge
    SCK_Pin VAR PORTC.0             'RC0    IN    SPI Clock Pin
    SDI_Pin VAR PORTC.1             'RC1    IN    SPI Data Input
    SDO_Pin VAR PORTC.2             'RC2    OUT   SPI Data Output
    SS_Pin VAR PORTC.3              'RC3    IN    SPI Chip Select
    
    'REGISTERS
    OSCCON = %11110010
    INTCON = %11000000
    PIE1 = %01001000
    APFCON0 = %00000000
    APFCON1 = %00000000
    TRISA = %00011111
    ANSELA = %00010111
    WPUA = %00000000
    TRISC = %00001011
    ANSELC = %00000000
    WPUC = %00000000
    ADCON0 = %00001100
    ADCON1 = %10100000
    
    'SPI Registers
    SSP1STAT = %00000000
    SSP1CON1 = %00100100
    SSP1CON2 = %00000000
    SSP1CON3 = %00010000
    
    'Interrupt Set up
    INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
    
    ;---------------------------------------------------------------------------
    wsave   VAR BYTE    $20     SYSTEM      ' location for W if in bank0
    ;wsave   VAR BYTE    $70     SYSTEM      ' alternate save location for W 
                                             ' if using $70, comment wsave1-3
    
    ' --- IF any of these three lines cause an error ?? ------------------------
    '       Comment them out to fix the problem ----
    ' -- Which variables are needed, depends on the Chip you are using -- 
    wsave1  VAR BYTE    $A0     SYSTEM      ' location for W if in bank1
    wsave2  VAR BYTE    $120    SYSTEM      ' location for W if in bank2
    'wsave3  VAR BYTE    $1A0    SYSTEM      ' location for W if in bank3
    ' --------------------------------------------------------------------------
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    SSP1_INT,  _SPI_Com,      PBP,  yes
            INT_Handler    AD_INT,    _Current_Pos,  PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
     
    high mce
    Thank you very much.

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: PIC16F1825 unable to Light an LED

    PORTA.5 is an external oscillator pin, and the default configuration is for the HS oscillator.
    Changing the OSCCON register to use the internal oscillator does not free the external oscillator pins.

    You'll need to set the configuration bits for the internal oscillator to be able to use those two pins.
    DT

  3. #3
    Join Date
    Apr 2012
    Location
    Leicester UK
    Posts
    21


    Did you find this post helpful? Yes | No

    Default Re: PIC16F1825 unable to Light an LED

    Thank you for the response.

    Ok. I thought that setting the OSCCON register to use the internal oscillator would have automatically freed those pins up. Right when I am home later I will look at that.

    Many thanks

Similar Threads

  1. LED PWM with High Frequencies?
    By RossWaddell in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 10th February 2013, 03:16
  2. Scrolling LED Badge Hack
    By ozarkshermit in forum Code Examples
    Replies: 0
    Last Post: - 23rd December 2012, 13:10
  3. One of 33 LED output Indicator
    By SOTASOTA in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 5th December 2012, 17:26
  4. Replies: 5
    Last Post: - 10th April 2011, 12:48

Members who have read this thread : 1

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