Basics/ru

= Основы =

Загрузчик
Загрузчик это небольшая программа запускаемая в микроконтроллере Pinguino (PIC18F or PIC32MX), предназначена для записи ранее скомпилированной программы для платы во флеш память микроконтроллера и последующего запуска этой программы.

Все коммерческие платы содержат записанный в микроконтроллер загрузчик.

Если вы сделали плату Pinguino самостоятельно, то в микроконтроллер необходимо записать загрузчик (может отличаться для разных плат) с помощью программатора PIC программатор.

8-bit Pinguino
В настоящее время существует 4 типа загрузчика, но только два из них поддерживаются(доступны для скачивания сдесь):


 * Версия 1 использовать только для микроконтроллера 18F2550(about 7K);


 * Версия 2 использовать для 18F2550 и18F4550 (about 7K).


 * Версия 3 is based on Diolan bootloader написан на ассемблере(about 1.5K). К сожалению не может работать совместно с SDCC. Отлично работает с MPLAB X.


 * Версия 4 is written with SDCC (>3.0.0), is less than 3K and is available for PIC18F 1xK50 (not tested), x455, x550, x6J50, x6j53 and x7j53 based Pinguinos, with Internal or External crystal, at low (not supported by the Pinguino IDE) or high speed USB.

При использовании версии 1 вы должны использовать кнопку запуска, иначе ничего не выйдет.

При использовании версии 2, 3 or 4 кнопка запуска может не использоваться так как загруженная программа запустится автоматически через 5 секунд (для версии 2), 10 секунд (для версии 3 и 4.12) после подачи питания или перезагрузки платы.

Обратите внимание, что загрузчик версии 4.13 и выше запускается после перезапуска платы и ожидает загрузку программы без ограничения времени. Выполнение пользовательской программы начинается сразу после завершения загрузки.

32-bit загрузчик
Все загрузчики для 32-bit плат вы можете найти сдесь.

Загрузка пользовательской программы
Прежде всего должна быть запущена Pinguino IDE.

Напишите вашу программу и скомпилируйте ее.

для 8-bit Pinguino
Существует несколько версий загрузчика.

In version 1 (see above) of the bootloader:

Push the reset button on your Pinguino board. The run led should remain dark. If it is lit, you have probably short circuited the run button with a jumper.

Click on the upload button and wait for the VascoBootloader to appear. Click the 'write' button in VascoBootLoader.

You should get something like PIC found followed by XXX.hex uploaded, XXX being the filename of your user program.

Now push the run button to start your program.

When using version 2 (see above) things get a little easier.

First press the reset button on the Pinguino Board. Then wait 3 seconds and click the upload button in the Pinguino IDE. The built-in led should stay on solid.

You should get something like Pinguino found followed by XXX.hex uploaded, XXX being the filename of your user program.

If you get 'Pinguino not found !!' you have not waited long enough, just click 'write' again.

If you get 'Pinguino found' followed by nothing you waited too long. In this case Reset your Pinguino board, wait 3 seconds and try again.

Using version 3 (see above).

First press the reset button on your Pinguino board. The built-in led should stay on solid. You now have 5 seconds to upload your program.

Second, click the upload button in the Pinguino IDE.

That's it !

You should get something like :  Pinguino found ... - with PIC18f26j50 (id=0x4c40) - with USB bootloader v4.x Writing User Application ... xxxxxxx.hex successfully uploaded Starting Application ... 

If you get:

 Pinguino not found Is your device connected and/or in bootloader mode ? 

you may have not connected your board or you may have waited too long after pressing the reset button before uploading your program. Try again from the beginning.

Using version 4 up to v4.11 (see above)

First press the reset button on your Pinguino board.
 * If you connect a USB cable between your PC and your Pinguino board, the bootloader waits 10 seconds for a program to be uploaded during which time the red LED blinks every half-second.
 * If the board is powered with an external power supply and the USB to PC cable is not connected, the bootloader waits about 5 seconds during which time the red LED stays lit.

Second, click the upload button in the Pinguino IDE.

That's it !

You should get something like :

 Pinguino found ... - with PIC18f26j50 (id=0x4c40) - with USB bootloader v4.x Writing User Application ... xxxxxxx.hex successfully uploaded Starting Application ... 

If you get:

 Pinguino not found Is your device connected and/or in bootloader mode ? 

you may have not connected your board via USB to your computer or you may have waited too long after pressing the reset button before uploading your program. Try again from the beginning.

Using version 4.12 and above

Versions 4.12 and above behave now differently from previous versions:


 * The user application starts without any delay on Power-on Reset
 * The bootloader starts only if Reset button has been pressed
 * The bootloader mode stays on until a program has been uploaded (no more time limit)
 * The led blinks at high frequency (T=2*43ms)

First press the reset button on your Pinguino board.

Second, click the upload button in the Pinguino IDE.

No hurry, take your time, the bootloader will wait until you press the upload button in the IDE.

That's it !

On a Pinguino 26j50, you should get something like :

 Pinguino found ... - with PIC18f26j50 (id=0x4c40) - with 62464 bytes free (61 KB) - with USB bootloader v4.xx Uploading user program ... xxxxx bytes written. xxxxx.hex successfully uploaded Starting user program ... 

On a Pinguino 47j53, you should get something like:

 Pinguino found ... - with PIC18f47j53 (id=0x58e0) - with 128000 bytes free (125 KB) - with USB bootloader v4.xx Uploading user program ... xxxxx bytes written. xxxxx.hex successfully uploaded Starting user program ... 

If you get :

 Pinguino not found Is your device connected and/or in bootloader mode ? 

you may not have connected your board via USB to your computer or not pressed the reset button.

on 32-bit Pinguino
Before telling the Pinguino IDE to upload your program you need to connect your board and put it in bootloader mode:

Press and hold down the user button BUT Press and release the user button RST (Reset) Release the user button BUT

You should now see the two built-in LEDs (yellow and green) flashing alternately. Now you and your Pinguino are ready to upload your program.

Once the upload is complete, the two LEDs will stop flashing and the program will start automatically.

To exit the bootloader mode without uploading a new program:-

Press and release the user button RST (Reset)

The two LEDs will stop flashing and the previously installed program will start running again.

Hello World example to run
Step 1

Prepare the connection to the Pinguino device by installing the MCHPCDC driver from :
 * Windows

..\PINGUINO\x4\extra\drivers\CDC\mchpcdc.inf or x4-easypack-rev999 instead of x4 according your installation (case of IDE version x.4).

Otherwise for other versions search the well-known MCHPCDC driver on the Web.

You will have a COMx connection once you have uploaded a program calling CDC functions. Then you will find this connection each time you will connect your Pinguino to a PC thru a USB cable. See Step 4 for more details about this connection.

Nothing to do.
 * Linux

Does not work with CDC functions at this time (November 2013).
 * OS X

Step 2: Write the following in the Pinguino IDE

Step 3: Compile and upload the code (see above)

Step 4:

You can use a terminal or console such as hyperterminal or putty to view the output. The settings are: Then start the connection. You get continuously Hello World!!! lines
 * Windows
 * Port: it depends. Normally it will be COM7. You can guess or you can check it. In Windows you can do this by right clicking on "my computer" -> manage -> device manager -> ports -> there should be a "communications port (COMx)" or "USB Serial Port (COMx)". The x is the number of your COM port. If there is none but you have a yellow question mark in the device manager, you need to (re)install the CDC driver.
 * Speed (Baud): 115200
 * Data bits: 8
 * Stop bits: 1
 * Parity: None
 * Flow control: none (or XON/XOFF)

If available save this connection for later use. You can use a Terminal Emulation Program such as Minicom : sudo minicom -o -D /dev/ttyACM0
 * Linux

Init function
TODO

Main function
TODO

Interrupt function
TODO

If an interrupt service routine changes variables which are accessed by other functions these variables have to be declared volatile. See Wikipedia (From the SDCC Documentation).