Hi,
I have some difficulties programming PIC32MM0064GPL020 (
https://www.digikey.ca/en/products/detail/microchip-technology/PIC32MM0064GPL020-I-ML/6098453)
I am able to successfully program this mcu, but it doesn't seem to be working. The led is either barely on or off all the time. Also, I supply 3V from pickit, but only get 1.75V on the led.
I have a feeling I made a mistake with my configuration bits.
Code:
#ifdef __XC32
#include <xc.h> /* Defines special funciton registers, CP0 regs */
#endif
// PIC32MM0064GPL020 Configuration Bit Settings
// 'C' source line config statements
// FDEVOPT
#pragma config SOSCHP = OFF // Secondary Oscillator High Power Enable bit (SOSC oprerates in normal power mode.)
#pragma config USERID = 0xFFFF // User ID bits (User ID bits)
// FICD
#pragma config JTAGEN = ON // JTAG Enable bit (JTAG is enabled)
#pragma config ICS = PGx1 // ICE/ICD Communication Channel Selection bits (Communicate on PGEC1/PGED1)
// FPOR
#pragma config BOREN = BOR3 // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware; SBOREN bit disabled)
#pragma config RETVR = OFF // Retention Voltage Regulator Enable bit (Retention regulator is disabled)
#pragma config LPBOREN = ON // Low Power Brown-out Enable bit (Low power BOR is enabled, when main BOR is disabled)
// FWDT
#pragma config SWDTPS = PS1048576 // Sleep Mode Watchdog Timer Postscale Selection bits (1:1048576)
#pragma config FWDTWINSZ = PS25_0 // Watchdog Timer Window Size bits (Watchdog timer window size is 25%)
#pragma config WINDIS = OFF // Windowed Watchdog Timer Disable bit (Watchdog timer is in non-window mode)
#pragma config RWDTPS = PS1048576 // Run Mode Watchdog Timer Postscale Selection bits (1:1048576)
#pragma config RCLKSEL = LPRC // Run Mode Watchdog Timer Clock Source Selection bits (Clock source is LPRC (same as for sleep mode))
#pragma config FWDTEN = ON // Watchdog Timer Enable bit (WDT is enabled)
// FOSCSEL
#pragma config FNOSC = PRI // Oscillator Selection bits (Low power RC oscillator (LPRC))
#pragma config PLLSRC = FRC // System PLL Input Clock Selection bit (FRC oscillator is selected as PLL reference input on device reset)
#pragma config SOSCEN = OFF // Secondary Oscillator Enable bit (Secondary oscillator (SOSC) is enabled)
#pragma config IESO = OFF // Two Speed Startup Enable bit (Two speed startup is enabled)
#pragma config POSCMOD = OFF // Primary Oscillator Selection bit (Primary oscillator is disabled)
#pragma config OSCIOFNC = OFF // System Clock on CLKO Pin Enable bit (OSCO pin operates as a normal I/O)
#pragma config SOSCSEL = OFF // Secondary Oscillator External Clock Enable bit (Crystal is used (RA4 and RB4 are controlled by SOSC))
#pragma config FCKSM = CSECME // Clock Switching and Fail-Safe Clock Monitor Enable bits (Clock switching is enabled; Fail-safe clock monitor is enabled)
// FSEC
#pragma config CP = OFF // Code Protection Enable bit (Code protection is disabled)
// #pragma config statements should precede project file includes.
// Use project enums instead of #define for ON and OFF.
#define SYS_FREQ 25000000
#include <xc.h>
void delay_us(unsigned int us)
{
// Convert microseconds us into how many clock ticks it will take
us *= SYS_FREQ / 1000000 / 2; // Core Timer updates every 2 ticks
_CP0_SET_COUNT(0); // Set Core Timer count to 0
while (us > _CP0_GET_COUNT()); // Wait until Core Timer count reaches the number we calculated earlier
}
void delay_ms(int ms)
{
delay_us(ms * 1000);
}
int32_t main(void)
{
ANSELA = 0x00;
ANSELB = 0x00;
TRISA=0x00;
TRISB=0x00;
OSCCON = 0b00000010;
PORTA=0x00;
PORTB=0xFF;
while(1)
{
PORTBbits.RB9 = 1;
delay_ms(1000);
PORTBbits.RB9 = 0;
delay_ms(1000);
}
return 0;
}
Simplified circuit is attached. 130ohm resistor is used.