Hey guys, unfortunately I ran into another problem. After getting the PIC32MX795F512L configuration bits and connections correct (using MPLAB X c32) I cannot get the program I have written to work without the PICkit 3 in use.
I have two AA batteries that I use when I disconnect the PICkit 3. I check the voltages over the MCLR resistor and it reads 3V, and I also tested that it is getting power with an LED. So, when I use the same LED for blinking in 1s intervals it only works with the PICkit 3 plugged in, otherwise when I use the two AA batteries, nothing happens (the LED does not blink). Here are the connections I am following:
https://www.electro-tech-online.com/custompdfs/2013/01/UBW32_MX795_schematic_v2621-1.pdf
The only difference is I am using two AA battteries, a 20MHz resonator, and I do not have any USB connections. I'm really not sure what the problem is and I could really use your guys expertise on this matter. Thanks.
EDIT:
When I uncheck "Power target circuit using PICkit 3" and then use the AA batteries it works when I run the program while still using the PICkit 3. However, when I disconnect the PICkit 3 it still runs on the AA batteries, but if I disconnect the batteries and reconnet them, then nothing happens. So, it seems the the PICkit 3 is initializing the uC to run in the first place. I'm really not sure how to change that...
Code:
/*
* File: main.c
*
* Purpose: To blink an LED, Test Timers, and interrupts
*/
// DEVCFG3
// USERID = No Setting
#pragma config FSRSSEL = PRIORITY_7 // SRS Select (SRS Priority 7)
#pragma config FMIIEN = OFF // Ethernet RMII/MII Enable (RMII Enabled)
#pragma config FETHIO = OFF // Ethernet I/O Pin Select (Alternate Ethernet I/O)
#pragma config FCANIO = OFF // CAN I/O Pin Select (Alternate CAN I/O)
#pragma config FUSBIDIO = OFF // USB USID Selection (Controlled by the USB Module)
#pragma config FVBUSONIO = OFF // USB VBUS ON Selection (Controlled by Port Function)
// DEVCFG2
// External Oscillator uses base 20MHz oscillator
#pragma config FPLLIDIV = DIV_5 // PLL Input Divider (4x Divider) Using 20MHz/5 = 4MHz
#pragma config FPLLMUL = MUL_20 // PLL Multiplier (20x Multiplier) 4MHz * 20 = 80Mhz
#pragma config UPLLIDIV = DIV_5 // USB PLL Input Divider (5x Divider) (USB module must have an input of 4MHz to multiply by 24 (96) and divide by 2 to get 48MHz for FS)
#pragma config UPLLEN = ON // USB PLL Enable (Disabled and Bypassed)
#pragma config FPLLODIV = DIV_1 // System PLL Output Clock Divider (PLL Divide by 1) => 80Mhz/1 => 80MHz
// DEVCFG1
#pragma config FNOSC = PRIPLL // Oscillator Selection Bits (Primary Osc w/PLL (XT+,HS+,EC+PLL))
#pragma config FSOSCEN = OFF // Secondary Oscillator Enable (Disabled)
#pragma config IESO = OFF // Internal/External Switch Over (Disabled)
#pragma config POSCMOD = XT // Primary Oscillator Configuration (HS osc mode)
#pragma config OSCIOFNC = OFF // CLKO Output Signal Active on the OSCO Pin (Disabled)
#pragma config FPBDIV = DIV_1 // Peripheral Clock Divisor (Pb_Clk is Sys_Clk/1)
#pragma config FCKSM = CSDCMD // Clock Switching and Monitor Selection (Clock Switch Disable, FSCM Disabled)
#pragma config WDTPS = PS1 // Watchdog Timer Postscaler (1:1)
#pragma config FWDTEN = OFF // Watchdog Timer Enable (WDT Enabled)
// DEVCFG0
#pragma config DEBUG = OFF // Background Debugger Enable (Debugger is disabled)
#pragma config ICESEL = ICS_PGx1 // ICE/ICD Comm Channel Select (ICE EMUC1/EMUD1 pins shared with PGC1/PGD1)
#pragma config PWP = OFF // Program Flash Write Protect (Disable)
#pragma config BWP = OFF // Boot Flash Write Protect bit (Protection Disabled)
#pragma config CP = OFF // Code Protect (Protection Disabled)
#include <p32xxxx.h>
#include <plib.h>
#include "delays.h" // must create own delays
#define LED1 LATBbits.LATB12
// Function Prototypes
// Note: In order to test code running via the pickit3 you must go to "Run" => "Set Project Configuration" => "Customisze..."
// => Select pickit3, then on side menu select pickit3
// => select "Power" from drop down menu at the top
// => check in "Power targe from circuit" and the voltage default is 3.25V, which is fine
int main(void) {
SYSTEMConfigPerformance(80000000); // predefined function from plib.h that optimizes access time to flash memory, enables the instruction
// and data caches, and enables the PIC32 cache module to jump ahead and read functions that aren?t being
// executed yet so there is often zero wait time for accessing those instructions
DDPCONbits.JTAGEN = 0; // disable the JTAG port
TRISBbits.TRISB12=0; // 0= ouput 1= input
AD1PCFG=0xFFFF; // pg. 144 of PIC32MX250F128B datasheet
LED1=0;
while (1)
{
LED1=~LED1;
delay_ms(1000); // 1000ms delay 1s delay
}
return 1;
}
I have two AA batteries that I use when I disconnect the PICkit 3. I check the voltages over the MCLR resistor and it reads 3V, and I also tested that it is getting power with an LED. So, when I use the same LED for blinking in 1s intervals it only works with the PICkit 3 plugged in, otherwise when I use the two AA batteries, nothing happens (the LED does not blink). Here are the connections I am following:
https://www.electro-tech-online.com/custompdfs/2013/01/UBW32_MX795_schematic_v2621-1.pdf
The only difference is I am using two AA battteries, a 20MHz resonator, and I do not have any USB connections. I'm really not sure what the problem is and I could really use your guys expertise on this matter. Thanks.
EDIT:
When I uncheck "Power target circuit using PICkit 3" and then use the AA batteries it works when I run the program while still using the PICkit 3. However, when I disconnect the PICkit 3 it still runs on the AA batteries, but if I disconnect the batteries and reconnet them, then nothing happens. So, it seems the the PICkit 3 is initializing the uC to run in the first place. I'm really not sure how to change that...
Last edited: