PDA

View Full Version : PIC16F1825 unable to Light an LED



Lestat
- 16th March 2013, 16:21
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.




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.

Darrel Taylor
- 16th March 2013, 18:04
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.

Lestat
- 16th March 2013, 18:38
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