![Pololu P-Star 25K50 Micro User Manual Download Page 24](http://html1.mh-extra.com/html/pololu/p-star-25k50-micro/p-star-25k50-micro_user-manual_1574946024.webp)
13. To compile the code, open the “Production” menu and select “Build Main Project”.
14. The “Output” pane should now show the build output from MPLAB X. This includes all the
command-line arguments passed to XC8 to compile the program, and all the output from the
compiler. You should see several instances of warnings similar to “warning: (1311) missing
configuration setting for config word 0x300000, using default”. This is OK, since the P-
Star’s configuration bits are set during manufacturing and they cannot be changed using the
bootloader.
15. One of the last lines of the output should say “Loading code from” and have the full path to
the HEX file produced during compilation. This path and filename will be important later when
you load the program onto the P-Star.
Where to find more information
For information about the hardware peripherals and registers on the PIC, see the
[http://www.microchip.com/PIC18F25K50]
[http://www.microchip.com/PIC18F45K50]
datasheet.
For information about MPLAB X, you can find useful resources under the “Help” menu and in the
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <xc.h>
#define _XTAL_FREQ 48000000
#define LED_GREEN(v) { TRISB7 = !(v); }
#define LED_YELLOW(v) { TRISB6 = !(v); }
#define LED_RED(v) { TRISC6 = !(v); }
void
main()
{
// Set up the LEDs
LATB7 = 1;
LATB6 = 1;
LATC6 = 0;
/* Enable Timer 0 as a 16-bit timer with 1:256 prescaler: since
the instruction speed is 12 MHz, this overflows about every 1.4
seconds. */
T0CON = 0b10000111;
while
(1)
{
TMR0L;
// trigger an update of TMR0H
// Blink the green LED with a period of 1.4 s
LED_GREEN(TMR0H >> 7 & 1);
// Blink the yellow LED with a period of 0.7 s
LED_YELLOW(TMR0H >> 6 & 1);
// Blink the red LED with a period of 0.35 s
LED_RED(TMR0H >> 5 & 1);
}
}
Pololu P-Star User’s Guide
© 2001–2019 Pololu Corporation
5. Getting started
Page 24 of 46