To generate this project using MPLAB Code Configurator (MCC), follow the next steps:
- 1.Create a new MPLAB X IDE project for
PIC18F47Q10.
- 2.Open MCC from the toolbar (more
information about how to install the MCC plug-in can be found here).
- 3.Go to Project Resources →
System → System Module and make the following configurations:
- Oscillator Select:
HFINTOSC
- HF Internal Clock: 1 MHz
- Clock Divider: 1
- In the Watchdog Timer Enable
field in the WWDT tab, WDT Disabled has to be selected
- In the Programming
tab, Low-Voltage Programming Enable has to be checked
- 4.From the Device Resources window, add
TMR0 and do the following configurations:
Timer0
Configuration:
- Enable Timer: checked
- Timer Clock tab
- Clock Source:
LFINTOSC
- Clock Prescaler:
1:32
- Postscaler: 1:1
- Timer mode:
16-bit
- Enable
Synchronization: unchecked
- Timer period: 10s
- Enable Timer Interrupt:
checked
- 5. Open Pin Manager → Grid
View window and select UQFN40 in the MCU package field and
make the following pin configuration:
- Set Port E pin 0 (RE0) as
output
Figure 1. Pin Mapping
- 6.Click Pin Module in the
Project Resources and set the custom name for RE0 to LED0.
- 7.Click Generate in the
Project Resources tab.
- 8.In the
main.c
file
generated by MCC, change or add the following code:
- Enable the Global and
Peripheral interrupts
- Light up LED0, wait 100 ms,
turn off LED0 and put the microcontroller to Sleep
- 9.
void main(void)
{
// Initialize the device
SYSTEM_Initialize();
// Enable the Global Interrupts
INTERRUPT_GlobalInterruptEnable();
// Enable the Peripheral Interrupts
INTERRUPT_PeripheralInterruptEnable();
while (1)
{
LED0_SetLow();
__delay_ms(100);
LED0_SetHigh();
SLEEP();
}
}