• AVR Freaks

Hot!PIC24F04KL100 cannot use RA5 as input

Author
inverterguru
New Member
  • Total Posts : 2
  • Reward points : 0
  • Joined: 2019/03/28 07:11:13
  • Location: 0
  • Status: offline
2019/03/29 12:26:28 (permalink)
0

PIC24F04KL100 cannot use RA5 as input

Hello,
 
I try to use the RA5 port as IO-Port., but there is an error message by programming the device.
With "#pragma MCLRE = ON" I can program the device, but the pin works as MCLR.
If I change to "#pragma MCLRE = OFF", I got an error message from the programmer (ICD3):
 
---------------------------------------------------------------------------
Target voltage detected
Target device PIC24F04KL100 found.
Device Revision ID = 2
 
Device Erased...
 
Programming...
 
The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x3ff
configuration memory
configuration memory
Address: f8000c Expected Value: 7b Received Value: fb
Failed to program device
---------------------------------------------------------------------------
 
Debugging works fine (but in this case, the pin function is MCLR).
I use MPLAB-X v5.15 an a ICD-3 Programmer/Debugger. Targed system is a PIC24F04KL100, Revision-ID 2. Voltage: 3,3V
 
Here my program:
---------------------------------------------------------------------------
// FBS
#pragma config BWRP = OFF // Boot Segment Write Protect (Disabled)
#pragma config BSS = OFF // Boot segment Protect (No boot flash segment)
 
// FGS
#pragma config GWRP = OFF // General Segment Flash Write Protect (General segment may be written)
#pragma config GSS0 = OFF // General Segment Code Protect (No Protection)
 
// FOSCSEL
#pragma config FNOSC = LPFRC // Oscillator Select (500KHz Low Power FRC with Postscaler (LPFRC))
#pragma config SOSCSRC = DIG // SOSC Source Type (Digital Mode for use with external clock on SCLKI)
#pragma config LPRCSEL = HP // LPRC Power and Accuracy (High Power/High Accuracy)
#pragma config IESO = OFF // Internal External Switch Over bit (Internal External Switchover mode disabled (Two-speed Start-up disabled))
 
// FOSC
#pragma config POSCMD = NONE // Primary Oscillator Mode (Primary oscillator disabled)
#pragma config OSCIOFNC = ON // CLKO Pin I/O Function (Port I/O enabled (CLKO disabled))
#pragma config POSCFREQ = HS // Primary Oscillator Frequency Range (Primary Oscillator/External Clock frequency >8MHz)
#pragma config SOSCSEL = SOSCLP // SOSC Power Selection Configuration bits (Secondary Oscillator configured for low-power operation)
#pragma config FCKSM = CSDCMD //CSECME // Clock Switching and Monitor Selection (Clock Switching and Fail-safe Clock Monitor Enabled)
 
// FWDT
#pragma config WDTPS = PS32768 // Watchdog Timer Postscale Select bits (1:32768)
#pragma config FWPSA = PR128 // WDT Prescaler bit (WDT prescaler ratio of 1:128)
#pragma config FWDTEN = OFF // Watchdog Timer Enable bits (WDT disabled in hardware; SWDTEN bit disabled)
#pragma config WINDIS = OFF // Windowed Watchdog Timer Disable bit (Standard WDT selected (windowed WDT disabled))
 
// FPOR
#pragma config BOREN = BOR3 // Brown-out Reset Enable bits (Enabled in hardware; SBOREN bit disabled)
#pragma config PWRTEN = ON // Power-up Timer Enable (PWRT enabled)
#pragma config I2C1SEL = PRI // Alternate I2C1 Pin Mapping bit (Default SCL1/SDA1 Pins for I2C1)
#pragma config BORV = V18 // Brown-out Reset Voltage bits (Brown-out Reset at 1.8V)
#pragma config MCLRE = ON //OFF // MCLR Pin Enable bit (RA5 input enabled; MCLR disabled)
 
// FICD
#pragma config ICS = PGx2 // ICD Pin Placement Select (EMUC/EMUD share PGC2/PGD2)
 
#include "xc.h"
 
void main(void)
{
    LATA = 0x0008;
   TRISA = 0x0008;
   ODCA = 0;
   _CN29PUE = 1;
   LATB = 0xc300;
   TRISB = 0x8300;
   ODCB = 0;
 
   for(;;)
   {
        LATAbits.LATA6 = 1;
        LATAbits.LATA6 = 0;
    }
}
---------------------------------------------------------------------------
 
What could be wrong?
 
Best regards,
inverterguru
 
#1

1 Reply Related Threads

    inverterguru
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2019/03/28 07:11:13
    • Location: 0
    • Status: offline
    Re: PIC24F04KL100 cannot use RA5 as input 2019/04/12 02:15:08 (permalink)
    0
    The solution:
    Project Properties -> ICD 3 -> Option category: Program Option -> "Use high voltage programming mode entry"


    #2
    Jump to:
    © 2019 APG vNext Commercial Version 4.5