Dany's PIC tips, software and projects in mE's mikroPascal


#Visitors since the 6th of August 2008:   Lastest update: 24 Apr. 2012.

new
MikroElektronika Forum mE Forum

MicroChip Forum
Microchip Forum


Janni's website
Janni's website
LibStock

Package manager

MikroProg/Suite


Content
Overview Short Description
Libraries (sources, .mcl files, packages): Usefull MikroPascal Units ("libraries"). (*): have are PIC24 version.

-->IMPORTANT: all libraries are compiled with mP PRO v5.00. The .mcl files are incompatible with older compiler versions!<--
Replacement Libraries Various PRO version libraries that replace/extend original libraries delivered with the compiler.
Additional Libraries Various PRO version libraries that are additional to the original libraries delivered with the compiler.
PIC Projects:
Small PIC projects showing different types of applications.
Code Snippets Small code parts that can be usefull.
Compiler and mikroPascal knowledge Things to know about mikroPascal, the mP compiler (versions) and the mE libraries.
Tips (general)
PIC24 Specific tips
PIC32, MMB MX4 and VTFT Specific tips
Various tips (software and hardware).
Articles Various articles (software and hardware).
Books Various books (software and hardware).
Tools Handy (development) Tools
Links (specification, documentation etc...) Links to interesting PIC related websites or pages.
PIC Forums Links to a number of PIC related user forums.
Contact author The contact data for the author of this website.
Disclaimer Disclaimer statement.



Libraries (sources, .mcl files, packages)

USB Libraries

Library Package file(s) Library Zip file(s)
USB_NA_pic.mpkg
USB_OA_pic.mpkg
USB_OA_PIC24.mpkg
newUSB_NA_PIC24.mpkg
USB_NA_pic.zip
USB_OA_pic.zip
USB_OA_PIC24.zip
newUSB_NA_PIC24.zip

Name Date Short description
USB units, New Architecture (NA).
2012-03-29 Set of USB units, permits creating composite USB devices.
For example projects and documentation, see the .mpkg or the .zip files.

Note: This set of NA units will exist next to the ones already presented below. The latter are meant to create simple USB (in the sense of "non composite") devices.

Important remarks:
  • CDC devices: Do not forget to add (if not already there) the VID and the PID of your device to the usbser.inf file (C:\Windows\inf).
    The entry in the usbser.inf file in the Windows directory has to look like:
    %DESCRIPTION%=DriverInstall, USB\VID_1234&PID_2000&MI_00
    where "xx" in "&MI_xx" is the number of the CDC interface.

  • CDC Devices: Every time you install (plug in) a CDC device with a new VID/PID combination, windows will give it a comportnumber that was not used before, so the used number always increases. If you want you can change it to a more acceptable number using the windows 'device manager'. Portnumbers already taken can be found in the registry: see NextSerialPortNo.

  • MSD devices: The library assumes the SDMMC card is always present and writable. Also hot swap is not allowed.
Also for PIC24. new
USB units, original architecture (OA). 2011-12-29
  • HID
    USB "HID" library. Creates a non composite USB HID device. Permits to read data from and write data to USB devices using the "HID" protocol (no driver at PC side required).
    For example projects and documentation, see the .mpkg or the .zip files

  • CDC
    USB "CDC" library. Creates a non composite USB CDC device. Permits to read data from and write data to USB devices using the CDC protocol (makes the USB device look like a serial port).
    2010-03-01: Capable of working with usbser.sys under windows (means Hyperterminal can be used), and also works under Linux (Thanks Rainer!).
    For example projects and documentation, see the .mpkg or the .zip files
    PP2 = PingPong version of the library.

    Important remarks:
    • Do not forget to add (if not already there) the VID and the PID of your device to the usbser.inf file (C:\Windows\inf).
    • CDC Devices: Every time you install (plug in) a CDC device with a new VID/PID combination, windows will give it a comportnumber that was not used before, so the used number always increases. If you want you can change it to a more acceptable number using the windows 'device manager'. Portnumbers already taken can be found in the registry: see NextSerialPortNo.

  • MSD
    USB "MSD" library. Creates a non composite USB MSD device. Makes the PIC (equipped with an SD/MMC card) look like an external drive to the PC (no driver at PC side required). For example projects and documentation, see the .mpkg or the .zip files.

    Important remarks:
    • The library assumes the SDMMC card is always present and writable. Also hot swap is not allowed.
Also for PIC24.
USB keyboard library, New Architecture (NA) 2011-05-08 USB keyboard library NA (new architecture).
Uses the USB_HID_Library_NA.mpas. Same specifications as the one below.
Example project.
USB keyboard library. 2011-05-03 USB keyboard library.
Supports also the "Sleep", "Wake-up" and "Power" keys.
Example project.
USB HID C ANSI MikroC Pro 2009.rar 2009-09-10 USB "HID" library, MikroC Pro 2009 version. More details...
Permits to read data from and write data to USB devices using the "HID" protocol (no driver at PC side required).
Author: Fabio Silva (alias Fabim at the mE forum).
Attention: Fabio is no longer supporting the version for mikroC 8.2.
joystick_USB_HID_C_ANSI.rar 2008-12-24 USB "HID" Joystick library, Mikro C version.
Permits to read data from a Joystick using the "HID" protocol (no driver at PC side required).
Author: Fabio Silva (alias Fabim at the mE forum).


FAT Libraries

Library Package file(s) Library Zip file(s)
Fat_pic.mpkg
Fat32_PIC24.mpkg
Fat_pic.zip
Fat32_PIC24.zip

Name Date Short description
Fat32 2011-08-04 Fat32 filesystem implementation, only for P18 and PIC24 PIC's. Details...
Can be configured for SPI (SD/MMC cards), CF (Compact flash cards) and IDE (Harddisk).
Example of usage: Tftp File Server (for Fat32 cards), see PIC Projects for details. Usage Templates
Documentation: Fat32 File System Specification, filename: "fatgen103.doc", and Fat32 structure information.
Fat32_2 new 2012-01-22 Fat32 filesystem implementation for PIC and PIC24. Details...
Same as above but can handle more than one file at a time, in possibly different directories.
Usage Templates for this library.
Fat16DirLFN 2009-10-09 Same as "Fat16Dir.mpas" (see below) but for long filenames. Details...
Fat16Dir 2009-10-10 Details...
IDE (Harddisk) 2010-10-03 Simple interface to access hards disks.
Usage template (ignore the Fat32 part...). IDE documentation.


Utility Libraries

Library Package file(s) Library Zip file(s)
Utilities_pic.mpkg
Utilities_PIC24.mpkg
Utilities_pic.zip
Utilities_PIC24.zip

Name Date Short description
StrngUtils 2011-08-04 A string utility library: trim, bcd, hex, binary, delete, copy, insert, stuff, pad and safe string concatenation, insertion, copy, stuff, pad, compare, pos etc.. functions. Functions working with constant strings are also available.
Can also be used together with the Janni/Yo2lio string replacement library. (only P18)

Provides
  • (almost) all routines present in above mentioned Janni/Yo2lio string replacement library, but written in Pascal (so, also usable for P16Fxxx PIC's).
  • also some temporary replacements for mE's StrCmp, StrStr and rTrim routines.
Test Software.

Also for PIC24.
SDMMC Utilities 2011-07-11 Several SDMMC routines to calculate card size, product name etc...

Also for PIC24.
PPS 2011-05-29 (simple) Library for selecting peripheral programmable pins.
Permits also to work with the "config2" "IOL1Way" set to "1" (IOlock protection enabled): the unlocking/locking activities are not done inside the pin setting routines here, they have to be done separately.
This means all peripheral in/out settings can be done after a reset and after that the final "IOlock" can be done.

If you use this lib, make sure it is always re-compiled for the project where it is used in.

Only for PIC24.
BitUtils 2011-03-24 Functions that returns "Bit" (0 or 1) values, plus functions that return "bit masks" for bytes, words and Dwords. Additionally, procedures are provided to set, get, clear and stuff bit groups inside a byte.
Routines to mimick bit arrays and boolean arrays using only one bit per boolean.
A routine to pick some grouped bits out of a byte array is also present.

Also for PIC24.
PascalFunctions 2011-06-21 Unit with a number of "standard" Pascal functions: odd, succ, pred, abs, sqr, trunc, round, frac and int.
Also the type "Sett" (replacement for Pascal's "Set" type) is present together with its functions to be used in mP. Example of the "set" usage.

Also for PIC24.
Asserts 2011-06-21 The reason for creating this unit can be found here. More details...

Also for PIC24.
Debug 2011-06-20 Permits usage of the Uart as a simple debugging data output tool, using Uartx as output device.

Also for PIC24.


PID Controller Library

Library Package file(s) Library Zip file(s)
PID_Lib_pic.mpkg
PID_Lib_PIC24.mpkg
PID_Lib_pic.zip
PID_Lib_PIC24.zip

Name Date Short description
PID_Lib 2011-11-01 A PID library with a fixed calculation time interval. Also for PIC24 now.
PID Documentation: here and here .
An extra article aboud PID implementation's drawbacks: here.
  • An "Integration Improvement" has been added to avoid the drawbacks of using the Integration actions (overshoot, ringing, instability, oscillating).
  • Also a "Differentiation Improvement" has been added to eliminate unnecessary delays when the error becomes smaller.


LCD Libraries

Library Package file(s) Library Zip file(s)
LCD_pic.mpkg LCD_pic.zip

Name Date Short description
LCD1602_4bits 2009-02-18 Routines to handle a 2 row 16 character LCD, alternative SW interface with respect to the mE library. Code size friendly. 4 bits interface. Works for LCDs equipped with the HD44780, KSU006 or equivalent controller (the same type of LCD the MikroPascal LCD library is for).
The port used by the LCD is selectable at initialisation time.
Connection diagram . Connection diagram with LCD reset .
LCD_4bits 2009-06-04 Same as LCD1602_4bits.mpas , but more generic. Capable of handling upto 4 rows of characters, and 16 or 20 columns per row. The init routine has now 1 parameter more: the number of columns.
Connection diagram and Connection diagram with LCD reset .


PS/2 Keyboard and Mouse Libraries

Library Package file(s) Library Zip file(s)
PS2_Keyboard_Mouse_pic.mpkg PS2_Keyboard_Mouse_pic.zip

Name Date Short description
PS/2 Keyboard library 2010-10-09 PS/2 keyboard library.
Returns the native PS/2 scan codes, no translation (except for some special scan codes, see the source file for the details).
Capable of writing to the keyboard (driving leds and giving commands to the keyboard).
Only tested on P18 with 48 MHz MCU clock (will work probably also on P16 and on lower MCU clock speeds).
Read keyboard example, Write keyboard example
Documentation: The list of the native PS/2 keyboard codes , Keyboard Scan Code Specification, Documentation about the PS/2 keyboard interface here, and here, PS/2 connector pinning + color of cable wires.
PS/2 Mouse library 2010-08-05 PS/2 Mouse library.
Returns the Delta X (hor), the Delta Y values (vert), the Delta Z (scrollwheel) values and the button status if one of those has changed.
Only tested on P18 with 48 MHz MCU clock (will work probably also on 16 and on lower MCU clock speeds). Read Mouse example. Documentation: The PS/2 Mouse interface and command list., Documentation about the PS/2 keyboard and mouse protocol, PS/2 connector pinning + color of cable wires.


RTC Libraries

Library Package file(s) Library Zip file(s)
RTC_pic.mpkg
RTC_PIC24.mpkg
RTC_pic.zip
RTC_PIC24.zip

Name Date Short description
RTCC_P24 2011-07-10 Usage example.

For PIC24 only.
RTC_PCF8583P

RTC_PCF8583P_SoftI2c
2009-03-19 Basic routines to control mE's Real Time Clock (RTC) with the PCF8583P.
RTC_PCF8583P usage example, RTC_PCF8583P_SoftI2c usage example
RTC2_DS1307

RTC2_DS1307_SoftI2c
2010-01-31 Basic routines to control mE's Real Time Clock (RTC2) with the DS1307.
RTC2_DS1307 usage example, RTC2_DS1307_SoftI2c usage example


RC5/RC6 Libraries

Library Package file(s) Library Zip file(s)
RC5_RC6_decoder_pic.mpkg RC5_RC6_decoder_pic.zip

Name Date Short description
Rc6_Decoder 2009-04-21 RC6 (Philips IR remote control system) decoder, decodes the Rc6 toggle, Rc6 System and Rc6 command. For the moment only RC6 "mode 0" (most used) can be decoded. Made for 36 Khz IR receivers with inverse output (= output active low), like the TSOP1736.
Usage example: Rc6_test.zip.
The decoder is interrupt based (the external interrupt is used) and uses timer 0. The current software is tuned to a CPU clock of 4 Mhz. For other clock speeds adaptations are needed (see text in the unit). RC6 Info
Rc5_Decoder 2009-04-21 RC5 (Philips IR remote control system) decoder, decodes the Rc5 toggle, Rc5 System and Rc5 command. Made for 36 Khz IR receivers with inverse output (= output active low), like the TSOP1736.
Usage example: Rc5_test .
The decoder is interrupt based (the external interrupt is used) and uses timer 0. The current software is tuned to a CPU clock of 4 Mhz. For other clock speeds adaptations are needed (see text in the unit). RC5 Info


Uart Libraries

Library Package file(s) Library Zip file(s)
Uart_buffered_pic.mpkg
Uart_buffered_PIC24.mpkg
Uart_buffered_pic.zip
Uart_buffered_PIC24.zip

Name Date Short description
UsartReceiver 2011-12-29 Usart Receiver routine(s) with circular receive buffer, interrupt driven. Not for PIC24.
Usage example.
mP projects using this library should contain a unit called "Project_Globals.mpas", holding the definition of the receiver's ring buffer size: "const UsartBuffSize = xxx;". This makes the buffersize definable for each project separately.

The mB implementation by "dangerous". Thanks!
UsartReceiver_P24 2011-06-23 Same as above, but for PIC24 only.
Usage example.
SoftUartReceiver.ppas (non PRO version) 2008-08-01 Soft Uart Receiver routine(s), non blocking, using external interrupt, with circular receive buffer.
Usage example: MainSoftUartReceiver.ppas


Memory Libraries

Library Package file(s) Library Zip file(s)
Memory_pic.mpkg Memory_pic.zip

Name Date Short description
MemManager_ 2011-04-28 Simple memory manager making dynamic variables possible in mP (procedures GetMem and FreeMem available). More details.
Usage example: Single Linked List.
EepromVariable 2009-04-22 Procedures that write and read the content of any type of variable to/from the internal PIC Eeprom.


Scheduler Libraries

Library Package file(s) Library Zip file(s)
Schedulers_pic.mpkg
Schedulers_PIC24.mpkg
Schedulers_pic.zip
Schedulers_PIC24.zip

Name Date Short description
TimeBase 2010-08-17 Permits elapsed time measurements in milliseconds or in seconds. Example project

Also for PIC24.
Cos 2011-06-25 Cos stands for Cooperative Operating System. More details. Example project P16/P18. Example project P24.

Also for PIC24.


Temperature sensor Libraries

Library Package file(s) Library Zip file(s)
TempSensors_pic.mpkg TempSensors_pic.zip

Name Date Short description
DS1820 2008-12-31 The basic functions for the DS1820 (digital temperature sensor), including string output, ready to display.
A routine to convert a temperature read from a DS18B20 to a string (to e.g. display on an LCD) is also present.
An example of its usage (with more than one DS1820 on the same OW bus) can be found in Ow.mpas. This is its project file. A more extended usage example is Thermostaat.zip . Other usage examples: Thermostat 001, Thermostat 003.



Replacement and additional libraries

Replacement Libraries

Name Short description replacement extension Author(s)
PIC18 Replacement Libraries Library replacement for PIC18s for mP PRO:
  • String library (__Lib_String)
  • Conversions library (__Lib_Conversions)
  • Delays library (__Lib_Delays)
  • Math library (__Lib_Math - two versions)
  • Floating-point math library (__Lib_MathDouble - two versions)
  • Internal EEPROM library (__Lib_EEPROM_256 and __Lib_EEPROM_1024)
  • Trigon library (__Lib_trigon)
  • System library (__Lib_System - two versions)
  • Pic Additional String Library (*)
(*) (Additional library, needed by the additional Ethernet libraries, see below, to be used if above "Conversions" library is also used)
yes yes Janni (All),
Yo2lio (Conversions and Strings)


Additional Libraries

Name Short description Author(s)
MikroPascal PRO PIC library mP4.60

MikroPascal PRO PIC library mP5.00
Set of libraries for mP PRO:
  • PIC Additional String Library(*)
  • Ethernet, both with and without ENC28J60, both with or without TC/IP stack
  • SD/MMC for SPI1 and SPI2
  • All input to digital
  • Bit manipulation
  • Flash memory
  • HW Zabbix Agent
  • Port expanders
  • LCD's
  • Sensirion
  • Temp and humidity measurements
  • etc...
Documentation and Usage Examples

(*) Needed by the Ethernet libraries. This version of "PIC Additional String Library" is not compatible with above "Conversions" replacement library (double definitions).
Use the special version of "PIC Additional Strings Library" delivered in "PIC18 Replacement Libraries" to avoid problems when using the above "Conversions" lib.

Related Forum thread.
Yo2lio
MikroPascal PRO libraries Set of units for mP PRO: Dany



Projects

USB Projects

Name Date Short description
PS/2 to USB translator for keyboard NA. 2011-04-30 Makes it possible to use a PS/2 keyboard on an USB connector on the PC. Uses the PS/2 Keyboard library and the USB HID Keyboard library NA (new architecture of USB units). Documentation: Translation table from PS/2 keyboard codes to USB keyboard codes.
PS/2 to USB translator for keyboard. 2010-09-26 Makes it possible to use a PS/2 keyboard on an USB connector on the PC. Uses the PS/2 Keyboard library and the USB HID Keyboard library. Documentation: Translation table from PS/2 keyboard codes to USB keyboard codes.


Http/Tftp/Telnet/... Projects

Name Date Short description
HTTP File Server (for Fat32 sd/mmc cards) 2011-01-16 Same as "Tftp File Server" (see below), but equipped with file download via HTTP (URL = 192.168.123.80).
More details on the Tftp part...
Uses the Ethernet ENC library v3_5 from Yo2Lio.

Attention: Tftp and Http can not be used at the same time.
Tftp File Server (for Fat32 sd/mmc cards) 2010-03-24 Same as "TFTP File Server", but for Fat 32 cards.
Supports subdirectories and longfilenames. More details ...
Uses the Ethernet ENC library v3_5 from Yo2Lio.
TFTP File Server, long filenames (for Fat16 sd/mmc cards) 2009-10-10 Same as "TFTP File Server" below, but for long filenames. Still no subdirs!
Uses the Ethernet ENC library v3_5 from Yo2Lio.
TFTP File Server (for Fat16 sd/mmc cards) 2009-10-10 This is a small TFTP fileserver, using an mmc/sd card for file storage. "Small" means the software does not have an error/retry/timeout mechanism. More Details...
Uses the Ethernet ENC library v3_5 from Yo2Lio.
Telnet to RS232 interface 2009-08-18 This device (hard- and software) can be used to control up to 6 RS232 devices via Telnet (Ethernet).
Uses the Ethernet ENC library v3_5 from Yo2Lio. More details...


RTC Projects

Name Date Short description
Usage of RTC (RTC1, PCF8583, HW I2c), Usart and AD convertor. 2009-02-03 Shows mE's RTC time and date on LCD (16x2) and sends it also to Uart (the latter only if the appropriate compiler switch is on). Additionally shows the AD value of AD channel 0 on the LCD. Uses some of the units present in section "PIC Units" above. For PICs with I2c and Uart hardware on board.
Usage of RTC (RTC1, PCF8583, Soft I2c) and (soft)Uart. 2009-02-03 Shows mE's RTC time and date on LCD (16x2) and sends it also to (soft) Uart (the latter only if the appropriate compiler switch is on). Uses some of the units present in section "PIC Units" above. For PICs without I2c or Uart hardware on board.
Usage of RTC (RTC2, DS1307, HW I2c) and Usart. 2009-02-06 Shows mE's RTC2 (DS1307) time and date on LCD (16x2) and sends it also to Uart (the latter only if the appropriate compiler switch is on). Uses some of the units present in section "PIC Units" above. For PICs with I2c and Uart hardware on board.
Usage of RTC (RTC2, DS1307, Soft I2c) and (soft)Uart. 2009-02-07 Shows mE's RTC2 (DS1307) time and date on LCD (16x2) and sends it also to (soft)Uart (the latter only if the appropriate compiler switch is on). Uses some of the units present in section "PIC Units" above. For PICs without I2c and Uart hardware on board.


Rc5/Rc6 Projects

Name Date Short description
Rc5/Rc6 receiver project, and
Remote Control project.
2010-05-31 Two IR remote control related projects (Rc5 and Rc6) Author is Remy.


Miscellaneous Projects

Name Date Short description
Small telephone exchange 2009-08-17 Small private telephone exchange, initially meant to make 2 modems (one connected to a "client", the other to a "server") communicate with each other to test a server/client system before e.g. putting the server on the web.
Warning: It is not the intention to connect this device to the public telephone network! More Details...
Line editor for PIC based servers 2010-05-23 Capable of, like a modem, receiving, editing and executing one (command) line of input.
The code in this example project shows a command line editor that can be used in servers (big word) you build, based on PIC's. More details...
PIC controlled thermostat. 27-08-2008 Usage of the Ds1820 (one wire temp sensor) to control heating system. Proportional control of the heater using PWM like method. Both circuit diagram and code is provided.
Pic Controlled Thermostat, Another example
Another example
12/04/2010 Usage of the Ds1820 (one wire temp sensor) to control heating system. Full documentation is provided (code, circuit diagram and explanations). Author is Remy.
PIC based timer 08-08-2008 Another example of using the 12F629 in a very small project. Switches off electrical appliances after a number of hours. Both circuit diagram and code is provided.
TouchDimmer (non PRO version) 14-05-2008 A small lamp operated by "touching" by hand its metal body. After each touch the lamp is starting to "burn" harder (3 intensity steps), with wrap around. Both schematic and sourcecode are provided. Based on the 12F629.



Code Snippets

Code Snippets

Name Short description
DumpBuffer.mpas Dumps the content of a byte array to the Uart, both hex and Ascii. Output example
CRC checks for the DS1820 (digital temp. sensor). Assumes the 9 DS1820 bytes present in a buffer and retruns zero if the calculated CRC out of it is Ok.
Also a CRC routine is foreseen for the "RomCode" (8 bytes) read from a DS1820.



Compiler and mikroPascal knowledge

Compiler and mikroPascal knowledge

Name Short description
Pitfalls in PIC usage and mikroPascal. List of pitfalls that can be encountered using PIC's and mP (list is not exhausting...).
Pointers in mikroPascal. Some elucidation and hints about pointer usage in mP PRO.
Chapters are: pointer declaration and usage, pointers to records, pointers to arrays, acessing a variable byte per byte, acessing a variable as being another type and pointer typecasting. Also a chapter on pointer arithmetic is present.
Code size, Ram Size and speed tips.
Code size tips from Dean.
Tips from janni.
Some tips that will make your code smaller and/or faster. Thanks for your forum post Dean!
I2c in mikroPascal Gives a short overview about I2c and how to use it in mP.
Numbers in mikroPascal Information about numbers: binary, decimal, hexadecimal and BCD coding.
Characters in mikroPascal About Characters and their Ascii codes, human readable strings representing a number, etc...
Strings in mikroPascal Article about how "strings" and "array of chars" are held in memory.
Bit handling. Handling "bits" in MikroPascal. Updated for v1.40.
Handling "Button"s Tips about usage of the "Button" library routine.
Code Setup Tips for beginners about how to setup the main program.
Beginners Tips Tips for brand new beginners.
The Read-Modify-Write problem How to avoid the Read-Modify-Write problem.
mE's HID library usage
The HID library usage: buffer declaration, HID interrupt, sending and receiving HID data.



Tips

Tips General (P12, P16, P18, P24)

Name Short description
Pitfalls in PIC usage and mikroPascal. List of pitfalls that can be encountered using PIC's and mP (list is not exhausting...).
SPI Timing Defining the timing parameters for SPI.
Automated Compiling of libraries in mikroPascal. Compiling libraries with dummy projects in batch files.
Website of Janni: mE's mikroPascal PRO for PIC tips, tricks & quirks Replacement libraries, mP PRO quirks, Tips and Tricks and Assembly Syntax
Which is better: Triac or Relay? Discussions about using triacs versus relays for switching mains loads.
Trouble with minimising the IDE. In case one can not minimise the IDE, simply goto the mP icon on the taskbar and play a little but with "Restore" and "Minimize"to make minimisation of the IDE work again. Also editing the ShowCmd line in the settings.ini: set it to 1 instead of 2 may help.
Simple Touch Detector. Tip from joseLB: This small code snippet is detecting touches.
The circuit is just a PIC alone in EP3, pull ups off, and no matter board leds for port A are on or off.
Remote Control Repeater. Tip from joseLB: Here is a TV, video, etc. remote control repeater Pascal code. It just get the signal arrived from up to 4 sources (4 places where you can put a TSOP receiver).
USB Switch. Tip from joseLB: This is a very simple USB 2.0 switch. With it you can switch a USB device betwen 2 PC's. Tested with penDrives of 1,2,4,16Gb, Vista, XP, USB1.0, USB 2.0.
20KWatts AC swithing. Tip from joseLB: The need was needing to switch on/off trifasic power up to 30Amps/phase, 220V~ = ~11KVA. Switching should be done even when there is no power supplied....
5V Switched Mode Power Supply. In applications with e.g. a PIC, an SD/MMC card reader, an Ethernet interface based on the ENC28J60 and an RS232 interface based on the Max232, the current drawn from the 5V power stabiliser becomes rather high. A heat sink is required for the stabiliser IC (usually an 7805, fed from an transformer via a bridge rectifier and a buffer elco). Things get worse if more components are added to the circuit: the heatsink must become bigger and bigger. Of course one can take a number of mesures to make the input voltage of the 7805 as low as possible (but not too low: stabilisation must still be possible), but even then the dissipation problem persists.
This circuit poses a solution to that problem. Details.
SPI problem and MicroChip Do NOT try to use the "SS" pin (SPI Slave Select) as digital input or output while using the SPI master mode.
In the MSSP engine there is (at least in some PIC's like the P18F2620) a silicon problem, making an SS pin change destroy SPI data.
Solution: set the SS pin (RA5 in the P18F2620) to output and never change its value.
SD/MMC QuickFormat for more than 512 files How to format an SD/MMC card in FAT 16 for more than 512 root directory entries.
Since the mmc_Fat_... routines only make use of the root directory, all files must be in it. As the number of root directory entries in Fat16 is defined during formatting (and thus fixed during usage of the SD/MMC card) and set to 512 by "mmc_Fat_Quickformat", this can cause a problem.
This piece of code allows to to format the card to have more than 512 entries/files in the root directory.
DumpBuffer.mpas How to dump the content of a byte array to the Uart, both hex and Ascii. Output example
"One transistor" switch. A digital switch consisting of only one transistor and 2 resistors.
RS232 to PIC interface RS232 interface based on discrete components. Only 1 RX and 1 TX line (but can be extended of course).
The "positive" Rs232 voltage is only 5V, but for most PC's that is no problem.
Using Leds, Buttons and Relays Tips about Leds, buttons and relays.
Creating multiple "software" timers in your program. Sometimes a (high) number of different timed activities has to be performed, e.g. creation of timeouts for expected events.
Since the number of timers in a PIC is limited, the trick is to use one hardware timer and derive a number of SW timers from it.
Orher related items (more advanced) are : TimeBase, simple time measurement. and Cooperative Operating System.
Creating a "Timebase" in your program. All about handling activities based on a "Timebase".
Orher related items (more advanced) are : TimeBase, simple time measurement. and Cooperative Operating System.
I2c in mikroPascal Gives a short overview about I2c and how to use it in mP.
X24Cxx (External Eeprom) addressing Gives the device write/read adresses for X24C02 .. X24C16
Ethernet Tips. Information about accessing Ethernet from a PIC:
- hardware configurations
- Ethernet libraries
- general tips regarding PIC's and Ethernet
RTC_Board_Pinning Pinning of the MikroElektronika Real Time Clock board.
USB PCB Connector_Pinning Pinning of USB A and B PCB connectors, copper side.
Important: D- should be connected to the PIC's RC4, D+ to the PIC's RC5!
Clock settings for USB devices
How to set the configuration words etc.. to set the correct USB and CPU clock speeds. For the PIC18F2455/2550/4455/4550 family. See also mE.
PIC USB related web sites (Microchip)
Links to PIC USB related websites on the Microchip forum.


Tips Specific for PIC24

Name Short description
Pitfalls in PIC24 usage and "mikroPascal for dsPIC30/33 and PIC24" List of pitfalls that can be encountered using PIC24's and mP (list is not exhausting...).


Tips Specific for mP for PIC32, MMB MX4 and VTFT

Name Short description
Pitfalls and tricks in mP for PIC32, MMB MX4 and VTFT List of pitfalls and tricks that can be encountered using mp for PIC32, MMB MX4 and VTFT (list is not exhausting...). Author: piort.



Articles

Articles

Name Short description
PID controller problems and their solutions. PID controller (I)ntegration and (D)ifferentiation problems and their solutions.
SPI Timing Defining the timing parameters for SPI.
Automated Compiling of libraries in mikroPascal. Compiling libraries with dummy projects in batch files.
PIC and USB. Author: Roy (roys29 on the mE forum). Forum link
Authors comment: I notice a lot of posts here regarding getting a PIC microcontroller to communicate with a PC via USB. After a couple of weeks of struggling myself I had some significant breakthroughs, and learned quite a bit in the process. So, I wrote down what I learned, created a PDF file, and posted it on the Internet to share in the hopes it would help someone else and possibly prevent them from going through weeks of steep learning and frustration like I did!
Thanks Roy!
Understanding analog to digital converter specifications. Confused by analog-to-digital converter specifications? Here's a primer to help you decipher them and make the right decisions for your project.
See also the AD considerations/tricks/practical explanations concerning this subject. Thanks Bill and JoseLB for drawing the attention to the article and the forumposts.
The read-modify-write problem (and how to avoid it). Almost every PIC programmer has had to deal with the Read-Modify-Write (RMW) problem at one point or another. Nowadays, it is (or should be) documented in most PIC tutorials and books, but the problem keeps coming up. The RMW problem could almost be considered a design flaw in the mid-range PICs (PIC16Fxxx) and programmers had to work around it using software techniques, but nowadays the PIC18Fxxxx series has built-in support to avoid it. Here's how you can use the new features of PIC ports to never have to deal with the issue.

Since above article does only suggests a solution for P18 pic's, this article shows how to do the same for P16 pic's and lower.
LCD documentation Articles: "How to use Intelligent LCDs". Discusses the same type of LCD the MikroPascal LCD library is for.
Beginners Checklist "Beginners checklist" for PIC MicroControllers.
PIC Tutorial Gooligum Electronics "PIC tutorials".
Peripheral Operations Guides Microchip's "Peripheral Operations Guides".
Application notes Microchip's "PIC application notes".
USB in a nutshell (well, not really) USB course from "Beyond Logic".
Important: In all USB documentation the words "IN" and "OUT" are frequently used to indicate the direction of data transfer. Those directions are always "USB host" (e.g. PC) related.
So, "IN" means data from the PIC to the host (data OUT from PIC point of view), "OUT" means data from the host to the PIC (data IN from PIC point of view).
USB made simple A Series of Articles on USB.
Designing a USB Keyboard and PS/2 Mouse Combination This application note describes how to design a USB keyboard and PS/2 mouse combination device using the Cypress Semiconductor single-chip CY7C63413 USB microcontroller. A lot of usefull information in this article, also for PIC users!
PIC Real Time Clock PIC REAL TIME CLOCK - 4 Methods For A Precision Time Clock.
Author: Xor. See also this website.
Mikroelektronika Articles Articles about Ethernet, Touchscreen, etc...



Books

Books

Name Short description
PIC MicroControllers The beginners MikroElektronika book "PIC MicroControllers" with examples of hardware and software.
mikroElektronika PIC books Other MikroElektronika books.



Tools

Tools

Name Short description
Project configuration in text format. new

Tool that shows the project's configuration words content, the MCU type and the MCU clock frequency.
This permits to add (part of) the configuration settings in a comment box in your project.
The tool only works when invoked from the IDE. See below "Tool Installation" for the settings.
Screen shot. Tool installation
User Libraries in the .MLK file

This tool permits to change the order of "user" libraries defined in the .MLK file of a certain processor. The correct order in the processor's .MLK file is needed because libraries that are "used" by others need to be defined "above" their "using" ones. The wrong order can occur if the "library dependancies" were not defined correctly or libraries were installed (usually manually) in a wrong order.
The tool only works when invoked from the IDE. See below "Tool Installation" for the settings.
Screen shot. Tool installation

This "correct" order of library definitions in the processor's .mlk file is only required if no source file is available or there are no "uses" statements in the source file.
Show PIC Data

This tool shows the PIC data (PIC capabilities) derived from the CSV files in the MikroProg Suite directory (and used by it). The files are installed together with the MikroProg suite installation. The CSV files themselves are generated by the "Export to XLS" function on e.g. this Microchip datasheet website.
Some original csv file columns are deleted, others are renamed for consistency between the diverse pic-type tables.
Clicking a column header sorts on the clicked column in ascending order. The sorting is "stable" (records that do not have to be moved are not).
ScreenShot.
Libraries for PIC/dsPIC/PIC32 (v2.1b).

The tool permits to select MCU's that have a certain set of libraries available. This is important when developing libraries in packages that rely on the existance of other libraries. The output of the tool can be imported in the package manager (with "paste from clipboard").
More info.
Compiling libraries in mikroPascal. Compiling libraries with dummy projects in batch files.
Library SwitchOver These 2 batchfiles can be used to switch over from Janni's replacement libraries to the original ones and vice versa.
USB DeView

USBDeview is a small utility that lists all USB devices that currently connected to your computer, as well as all USB devices that you previously used. For each USB device, exteneded information is displayed: Device name/description, device type, serial number (for mass storage devices), the date/time that device was added, VendorID, ProductID, and more... USBDeview also allows you to uninstall USB devices that you previously used, disconnect USB devices that are currently connected to your computer, as well as to disable and enable USB devices. You can also use USBDeview on a remote computer, as long as you login to that computer with admin user.
PC board diagnostic tool The ROCKKIT BOARD TESTER is an innovative and affordable IN-CIRCUIT board tester.
Comment from Ed Anderson (Rotary_Ed on the mE forum)
RamSizes: Display of variables per project entity. (v5.1)

For mP, mC and mB PRO for PIC and dsPIC/PIC24.

This tool shows the size of variables splitted up per unit/module and procedure/function.
ScreenShot , Tool settings in the IDE (Options-Tools), More Details...

IMPORTANT:
- Be sure that "Include Source Lines in the Output Files and Generate Listfile, include debug info" is checked in menu Tools -> Options -> Output -> OutputSetting.
- Compile the project before tool usage.

List of hidden variables is adapted for Pic's supported in mP PRO for PIC v4.80 bèta.

Also PIC24 compliant!
Display of used rom size. (v 4.5)

For mP, mC and mB PRO for PIC.

This tool shows the romsize of all units of a project together with rom-size details of a selected unit.
ScreenShot, Tool settings in the IDE (Options-Tools), More Details...

IMPORTANT:
- Be sure that "Include Source Lines in the Output Files, Include ROM Constants and Generate Listfile, include debug info" is checked in menu Tools -> Options -> Output -> OutputSetting.
- Compile the project before tool usage.

Also PIC24 compliant!
Display of used global variables (and more) of a routine (v4.1)

* Shows, from a selected routine, the following items:
  • The parameters
  • The (used) local variables
  • The unused local variables (eliminated by optimiser)
  • The used global variables
  • Called routines
* Shows also which routines use a selected Global variable.
ScreenShot, Tool settings in the IDE (Options-Tools)

IMPORTANT:
- Be sure that "Include Source Lines in the Output Files and Generate Listfile, include debug info" is checked in menu Tools -> Options -> Output -> OutputSetting.
- Compile the project before tool usage.

Also PIC24 compliant!
Function calls display (v9.0)





For mP, mC and mB PRO for PIC.

PIC24, dsPIC30 and dsPIC33 compliant!

Shows the function calls (1 level deep) of the project in a number of views:
  • which functions use which other functions (-1- left main window)
  • which functions are used by other functions (-2- right main window)
Additionally the following info is given:
  • the (deepest) stack call level, the needed stack depth and the call frequency of a function (3)
  • the deeptest call stack (the names of its subsequent called functions) of a function (4)
  • the full call stack (the names of its subsequent called functions) of a function (5)
(1), (2) and (3): see ScreenShot
(4) and (5): see ScreenShot

Selecting a function in one view shows all its occurences in the other view.
Double clicking a function goes "down" in the call stack in the "uses" view, and "up" in the call stack in the "is used by" view.
Right clicking a function shows its call stacks in a separate screen.

The call tree of the last selected function in one of both main windows can be shown graphically (and saved to a file).
The call depth shown can be limited in the graphical view. One can click one of the procedures on the screen to see its caller tree, and go to previous procedures selected via the history. Single functions (and their callees) or all functions from specific libraries can be ingored in the graphicall call tree.

The inverse graphical tree (which routines do call the selected one) is also provided.

The Project's Module tree (which modules/units use other modules/units) and a Module's Routine tree (the call graph of all routines inside a module/unit) are also present.

Keep in mind that all info that you see is that of the current project. This means e.g. that unused procedures are not shown!
So: always compile the project before tool usage, the tool needs the listfile and the callertable.

Tool settings in the IDE (Options-Tools).
Pascal Source Code formatter (v1.12)

This tool is a simple Pascal source code formatter, mainly making correct and readable code indentation. It is started up from the IDE and gets the currently selected file. More details...

Also PIC24 compliant!
PIC Clear Project (v14)

This tool enables you, in case of troubles, to delete the derived files (*.mcl etc...) in the project directories and the "Defs" directory. It is the only way to achieve a "build all".
Additionally there is the possibility to check some items in the project file (*.mpppi), edit it if necessary, show the actual library filenames of libs checked in the library manager and show the project's listing file (*.lst).

The tool is integrated (= can be started up from within) the IDE, but can also be used stand alone. More details...

Also PIC24 compliant!
Also "Packages compliant" now from v14 onwards.
PIC Timer Calculator by Ronald Nisblé.

This tool maybe can help you to calculate the right timer configuration for your PIC Microcontroller.
THIS PROGRAMM IS FREEWARE FOR NON COMERCIAL USE!
Open pictimercalculator.exe (v0.9.6) in a hex editor and change the byte at offset 28E18 from 84 to 8E to use it in 2012.
PIC Timer Calculator
by "Dring Engineering services".
PIC Timer Calculator and Source Code (Basic) Generator.
PIC Interrupt code generator
by "Dring Engineering Services"
Generates the Basic code needed for various interrupts on the PIC 16F877A.
It should work for for similar chips with similar registers.
PIC PWM Calculator & Code Generator This calculator will save you from insomnia and headaches !
It will help you to configure the PIC TIMER2 and PWM modules, you will also get a ready-to-use C source code (for MikroC compiler).
PIC PWM Register Calculator
by "Dring Engineering Services"
Use the calculator to generate the parameters for the PWM Registers.
It was designed for the 16F877A, but will work for all chips with the same Registers.
It calculates the Registers for all possible values of the prescaler.
PIC Project Code Wizard
by "Dring Engineering Services"
Generates the initialisation and interrupt code (Basic) needed for different configurations for a few popular PIC's.
Limited functionality for now.



Links

PIC related Website Links (Specification, documentation etc...)

Link Short description
Website of Janni: mE's mikroPascal PRO for PIC tips, tricks & quirks Replacement libraries, mP PRO quirks, Tips and Tricks and Assembly Syntax
Embedded Lab An online teaching laboratory for Microcontrollers and Embedded Systems.
Translate.pdf PS/2 Keyboard codes to USB keyboard codes translation.
USB Specification, overall,
USB Specification, Classes ,
USB Specification, HID Class ,
USB Class codes ,
HID device class definition ,
USB PCB Connector_Pinning (copper side) ,
Clock settings for USB devices ,
Clock settings for USB devices (mE) ,
PIC USB related web sites (Microchip) ,
Designing a USB Keyboard and PS/2 Mouse Combination,
USB Keyboard and Mouse
USB Related (Specification) documents
Tips and Tricks (Microchip)
Compiled Tips ‘N Tricks Guide from Microchip.
The PS/2 Protocol,
The list of the native PS/2 keyboard codes ,
Keyboard Scan Code Specification,
The PS/2 keyboard interface,
The PS/2 mouse interface,
The PS/2 Mouse/Keyboard Protocol,
PS/2 Keyboard codes to USB keyboard codes translation.
PS/2 documentation.
SPI Documentation Serial Peripheral Interface Bus documentation
SDMMC Specification
Secure Digital specification (types, features, speeds)
SDMMC Simplified specification.
IDE Hard Disk experiments (?)
Using an IDE Hard Drive with a 8051 Board and 82C55 Chip (PJRC)
Connecting IDE Drives (by Tilmann Reh)
IDE Controller (Wesleys PIC pages)
IDE - Hardware Reference & Information Document (Alex T. Ivopol)
IDE (harddisk interface) documentation.
Fat32 structure information
Fat32 File System Specification
Fat32 Structure information.
Fat32 File system specification, filename: "fatgen103.doc".
MicroControllers Projects and Forums Several worked out projects using PIC's. Great PIC applications!
TFTP information
RFC
Information about the TFTP (Trivial File Transfer Protocol).
FAT 16 information (MMC/SD cards)
FAT16 bootsector info.
Also here and here.
Information about the FAT16 Directory table and its bootsector.
MicroChip Technology User Forums Links Links to reference manuals, General Circuit-Design-Questions, PCB Layout Design and Considerations,
Analog Input Questions, Digital Input Questions, Output Questions, Connection Questions, Useful external parts,
Decoding the markings on parts, Learning about electrics and electronics, Microchip Tool Questions and Interesting topics, which doesn't suite into a previous one.
Thanks Stefan!
PIC Product Selector. PIC MCU Product Selector (MicroChip).
PIC DataSheets. PIC Datasheet website (MicroChip).
Application notes Microchip's "PIC application notes".
I2C specification.
I2C manual.
I2C Wiki.
I2c documentation.
The GANSSLE group Jack Ganssle is on a mission to help embedded developers produce better embedded products faster, while maximizing the fun of creating new products!
Embedded SW development "The official site of the Embedded Development Community"



PIC Forum links

PIC Forum links


MikroElektronika Forum

MicroChip Forum



Your remarks
Your remarks, comments or questions please:

Thank You.


Disclaimer

DISCLAIMER

THIS SOFTWARE IS PROVIDED BY THE AUTHOR “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

-------------------------------------------