Pololu P-Star 25K50 Micro Скачать руководство пользователя страница 33

7. Programming using the PICkit 3

Warning:

Using a PICkit to program the P-Star will permanently erase its USB bootloader,

so you will not be able to program it over USB using the Pololu USB Bootloader Utility. It will
also erase the serial number of the device.

The

PICkit 3

[http://www.microchip.com/pickit3]

from Microchip is a hardware debugger and programmer

for PIC microcontrollers that can be used to program the P-Star.

The PICkit 3 has a female header with six pins. Five of these pins need to be connected to the P-Star
in order to program it:

• Pin 1 of the PICkit 3, which is indicated with a triangle on the PICkit’s case, connects to the

P-Star’s MCLR pin.

• Pin 2 connects to VDD.

• Pin 3 connects to GND.

• Pin 4 connects to RB7 (also known as PGD).

• Pin 5 connects to RB6 (also known as PGC).

• Pin 6 should be left unconnected.

In addition to making these connections, the P-Star must also be powered (the PICkit 3 does not
supply power).

The picture below shows one way to connect a P-Star to a PICkit 3. An upwards-pointing 1×4 male
header is soldered to VDD, GND, RB7, and RB6. These pins are connected to the PICkit 3 with

male-

female premium jumper wires

[https://www.pololu.com/category/67/male-female-premium-jumper-wires]

. The

MCLR pin is connected to the PICkit 3 through the breadboard and a

male-male premium jumper

wire

[https://www.pololu.com/category/68/male-male-premium-jumper-wires]

The PICkit 3 must be connected

via USB to a computer, and the P-Star needs to be powered either from its USB port or from the VIN
pin. The picture below shows a P-Star 25K50 Micro, but the same setup could be used with P-Star
45K50 Mini as well, since the 5 ICSP pins are in the same position.

Pololu P-Star User’s Guide

© 2001–2019 Pololu Corporation

7. Programming using the PICkit 3

Page 33 of 46

Содержание P-Star 25K50 Micro

Страница 1: ...s 16 5 2 Getting into bootloader mode 17 5 3 Compiling a program with MPLAB X and XC8 19 5 4 Programming using p load 25 6 The P Star Bootloader 26 6 1 Memory organization 26 6 2 Startup procedure 27...

Страница 2: ...product 2072 not included to connect to a computer Features and specifications Programmable Microchip PIC18F25K50 or PIC18F45K50 microcontroller 32 KB flash 8 KB used by bootloader leaving 24 KB avai...

Страница 3: ...ated current 1 100 mA 500 mA Auxiliary 3 3 V regulator Dimensions 1 0 6 2 0 0 7 Weight 2 1 3 g 3 5 g 1 These values are rough approximations for comparison purposes Available current depends on input...

Страница 4: ...Star You can contact us https www pololu com contact directly or post on our forum http forum pololu com Tell us what we did well what we could improve what you would like to see in the future or any...

Страница 5: ...Star 25K50 Micro The diagram is also available as a printable PDF https www pololu com file 0J799 p star 25K50 micro pinout pdf 161k pdf For more information about the PIC18F25K50 microcontroller and...

Страница 6: ...port via a USB A to Micro B cable https www pololu com product 2072 not included The USB connection can be used to transmit and receive data from the computer and a preloaded USB bootloader makes it p...

Страница 7: ...e operating no matter how low VIN is When the P Star 25K50 Micro is being powered through VIN regardless of whether USB is connected the sum of the 5V output current GPIO output current and current us...

Страница 8: ...fboards breadboards https www pololu com category 28 solderless breadboards or 0 1 female connectors https www pololu com category 50 0 1 2 54 mm female headers P Star 25K50 Micro with included option...

Страница 9: ...tar 25K50 Micro schematic diagram This schematic is also available as a PDF P Star 25K50 Micro schematic diagram Pololu P Star User s Guide 2001 2019 Pololu Corporation 3 P Star 25K50 Micro Page 9 of...

Страница 10: ...k pdf Dimension diagram A dimension diagram is available as a PDF P Star 25K50 Micro dimension diagram https www pololu com file 0J798 p star 25K50 micro dimensions pdf 202k pdf Pololu P Star User s G...

Страница 11: ...ini SV P Star 45K50 Mini SV bottom view 4 1 P Star 45K50 Mini SV pinout and components P Star 45K50 Mini SV pinout diagram Pololu P Star User s Guide 2001 2019 Pololu Corporation 4 P Star 45K50 Mini S...

Страница 12: ...D serves as an indicator for when the board is transmitting serial data If you are not using serial the LED can be used as a normal LED To avoid interference with connected serial devices the bootload...

Страница 13: ...to USB power For example this could allow a battery powered device to turn off the regulator and avoid draining its battery while it is connected to a computer USB power input The P Star can be powere...

Страница 14: ...y default BATLEV is connected to the RE1 pin through a cuttable trace on the bottom of the board This means that RE1 can be used as an analog input to measure the external power supply voltage Cutting...

Страница 15: ...shown with a vertical 5 pin ICSP programming header installed 4 2 P Star 45K50 Mini SV schematic and dimensions Schematic diagram A schematic diagram is available as a PDF P Star 45K50 Mini SV schemat...

Страница 16: ...vices category but if your P Star was set up with an older driver then it might still be in Pololu USB Devices Mac OS X If you are using Mac OS X you should download and install the Pololu USB Bootloa...

Страница 17: ...tton The P Star will go into bootloader mode if the RB6 line is high immediately after a reset This will work no matter what type of application is loaded on the P Star For example if your P Star is o...

Страница 18: ...If the application uses USB it should disable the USB module by clearing USBEN and then wait for at least 100 ms before starting the bootloader in order to give the computer time to detect that the ap...

Страница 19: ...Microchip for 8 bit PICs Both programs run on Windows Max OS X and Linux 1 Download and install the latest versions of MPLAB X http www microchip com mplabx and XC8 http www microchip com compilers 2...

Страница 20: ...t use MPLAB X to the load the program onto the board 7 For the compiler select XC8 8 For the Project Name choose something like p star1 and choose the folder you want it to be in Click Finish to creat...

Страница 21: ...akes up the first 8 KB of flash memory In the File menu select Project Properties In the XC8 linker category select the Additional options sub category In the Codeoffset box enter 0x2000 which is 8 10...

Страница 22: ...by opening the Window menu and selecting Projects Left click the sign next to Source Files to expand it and verify that your project has no source files yet Then right click on Source Files select Ne...

Страница 23: ...in and then click Finish This should create a new file named main c and open it for editing 12 Copy and paste the following code into main c Pololu P Star User s Guide 2001 2019 Pololu Corporation 5 G...

Страница 24: ...tion about the hardware peripherals and registers on the PIC see the PIC18F25K50 http www microchip com PIC18F25K50 PIC18F45K50 http www microchip com PIC18F45K50 datasheet For information about MPLAB...

Страница 25: ...mething like Device Pololu P Star 45K50 Bootloader Serial number 00203525 Erasing flash Progress Done Erasing EEPROM Progress Done Writing flash Progress Done Sent command to restart device The w opti...

Страница 26: ...uld correspond to a NOP Entry and interrupt vectors The entry vector and interrupt vectors are remapped by the bootloader to the beginning of the application section The application s entry vector sho...

Страница 27: ...as an ASCII string with a null terminator byte The extra bytes after the null terminator are all set to zero Addresses 0x80 0xA1 contain the serial number in USB string descriptor format The extra by...

Страница 28: ...D are used to communicate with the USB host RB6 is driven high to turn on the yellow LED but never driven low RB7 is driven high to turn on the green LED but never driven low The bootloader does not u...

Страница 29: ...C18F25K50 and PIC18F45K50 have several configuration bits in flash memory For the P Star the values of those configuration bits are shown in the table below These configuration bits cannot be changed...

Страница 30: ...ig WDTPS 256 CONFIG3H pragma config PBADEN ON pragma config SDOMX RB3 pragma config CCP2MX RC1 pragma config T3CMX RC0 pragma config MCLRE ON CONFIG4L pragma config STVREN ON pragma config LVP ON prag...

Страница 31: ...ls The CPU takes at least 4 cycles to execute a single instruction so it can execute up to 12 million instructions per second 12 MIPS The PCLKEN configuration bit is set to 0 so it is possible to shut...

Страница 32: ...be enabled by setting the SWDTEN bit in the WDTCON register The watchdog postscaler is set to 1 256 so the watchdog timer s period is about 1048 ms Read write protection The region of flash memory occ...

Страница 33: ...Pin 6 should be left unconnected In addition to making these connections the P Star must also be powered the PICkit 3 does not supply power The picture below shows one way to connect a P Star to a PIC...

Страница 34: ...be directly connected to this five pin header or it could be connected through a set of male female premium jumper wires https www pololu com category 67 male female premium jumper wires This configur...

Страница 35: ...5 pin programming header installed P Star 45K50 Mini SV on a breadboard shown with a vertical 5 pin ICSP programming header installed Pololu P Star User s Guide 2001 2019 Pololu Corporation 7 Program...

Страница 36: ...programs for the P Star that show how to use the USB interface and other parts of the P Star The README md file in the repository has instructions for building the examples with the MPLAB Xpress onli...

Страница 37: ...load it as a ZIP archive be sure to extract the files from the ZIP archive before continuing 3 Run the MPLAB X IDE 4 In the File menu select Open Project and navigate to apps hid_mouse MPLAB X Select...

Страница 38: ...other example app in M Stack except for the bootloader app Where to find more information We recommend reading the README txt file that comes with M Stack For information about USB see the USB 2 0 Sp...

Страница 39: ...s two types of code absolute and relocatable These instructions will show how to write absolute code where the location of every instruction and variable is known ahead of time The alternative is relo...

Страница 40: ...this choice does not matter because we will not use MPLAB X to the load the program onto the board 7 For the compiler select MPASM 8 For the Project Name choose something like p star1 and choose the...

Страница 41: ...category check the Build in absolute mode check box then click OK 10 Now we need to create the assembly source file Locate the Projects pane If the Projects Pololu P Star User s Guide 2001 2019 Pololu...

Страница 42: ...If pic_8b_simple asm is not visible in the menu you can find it by selecting Other Microchip Embedded and then MPASM assembler 11 Choose a file name such as main and then click Finish This should cre...

Страница 43: ...eet For information about MPLAB X you can find useful resources under the Help menu and in the docs directory inside your MPLAB X installation 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22...

Страница 44: ...your MPLAB X installation If you have questions you can post in Microchip s MPASM forum http www microchip com forums f16 aspx or the Pololu Robotics Forum http forum pololu com Pololu P Star User s G...

Страница 45: ...CBASIC PRO http store melabs com cat PBP html MicroCode Studio with a simple program for the P Star 25K50 Micro 1 Download and install PICBASIC PRO from the PICBASIC PRO Compiler Downloads page http p...

Страница 46: ...k Next 9 For the Programmer Filename enter p load exe Click Next 10 Click the Find Manually button and select the p load bin folder If you installed p load in the default location the bin folder can b...

Отзывы: