Difference between revisions of "DsPIC30F 5011 Development Board"

From OpenCircuits
Jump to navigation Jump to search
(order pharmacy online)
m (Reverted edits by ColeenRosales (Talk) to last revision by Russ hensel)
 
(197 intermediate revisions by 28 users not shown)
Line 1: Line 1:
  Cool site.Very good!!!
+
This project aims to provide the development tools for building a [[Multi-purpose_Embedded_System | multi-purpose MCU board]]. Description is based on Microchip dsPic33FJ256GP506 (was dsPic30F5011), but information provided in this wiki may give useful directions for developing similar embedded systems with different platforms.
..............................................................
 
  The following links are to pages containing information
 
about most popular onliine casinos:
 
  
- <a href=http://pokerstars.hut2.ru/>poker star</a>
+
==Introduction==
- <a href=http://partypoker.hut2.ru/>party poker</a>
 
- <a href=http://onlinepoker.hut2.ru/>online poker</a>
 
- <a href=http://casinobonus.hut2.ru/>casino bonus</a>
 
- <a href=http://bestcasino.hut2.ru/>best casino</a>
 
- <a href=http://virt-casino.hut2.ru/>virtual casino</a>
 
- <a href=http://internetcas.hut2.ru/>internet casino</a>
 
- <a href=http://blackjackcas.hut2.ru/>black jack card</a>
 
- <a href=http://casblackjack.hut2.ru/>casino black jack</a>
 
- <a href=http://onlcasbonus.hut2.ru/>online casino bonus</a>
 
..............................................................
 
  The following links are to pages containing information
 
about most popular drugs:
 
  
- <a href=http://somapill.hut2.ru/> soma </a>
+
===Features of dsPic33FJ256GP506===
- <a href=http://ultrampill.hut2.ru/> ultram </a>
+
*3.0 to 3.3&nbsp;V
- <a href=http://fioricet.hut2.ru/> fioricet </a>
+
*Up to 40&nbsp;MIPs
- <a href=http://buy-cialis.hut2.ru/> buy cialis </a>
+
*Maximum current sink/source for I/O pins: 4&nbsp;mA
- <a href=http://viagrabuy.hut2.ru/> buy viagra </a>
+
*16-bit arithmetics
- <a href=http://buylevitra2.hut2.ru/> buy levitra </a>
+
*DSP Instruction Set
- <a href=http://carisoprodol.hut2.ru/> carisoprodol </a>
+
*Dual programming techniques: ICSP and RTSP
- <a href=http://phenter-mine.hut2.ru/> phentermine </a>
+
*Memory
- <a href=http://tramadonline.hut2.ru/> tramadol online </a>
+
**256&nbsp;KB flash (86K instructions)
- <a href=http://bxanaxonline.hut2.ru/> buy xanax online </a>
+
**16&nbsp;KB RAM (incl. 2&nbsp;KB DMA RAM)
- <a href=http://buypropecia.hut2.ru/> buy propecia </a>
+
**No EEPROM
- <a href=http://buyhydrocod.hut2.ru/> buy hydrocodone </a>
+
*Communications ports
- <a href=http://cuturl.com?newviagra/> buy viagra</a>
+
**UART
- <a href=http://cuturl.com?newphentermine/> buy phentermine </a>
+
**I<sup>2</sup>C: up to 1&nbsp;Mbit/s
- <a href=http://cuturl.com?newtramadol/> buy tramadol </a>
+
**SPI
- <a href=http://cuturl.com?propecia/> buy propecia </a>
+
*ADC
 +
*10-bit A/D, 1.1 Msps
 +
*12-bit A/D, 500 ksps
 +
*No DAC (PWMs only)
 +
*Pin-to-pin compatible with other dsPICs
 +
{| border="1" cellspacing="0" cellpadding="5"
 +
|+ Comparison between different dsPICs
 +
! dsPic !! *Price<br>US$ !! MIPs
 +
! Flash<br>(kB)!! RAM<br>(kB) !! EEPROM<br>(kB)
 +
! I/O !! ADC<br>12-bit !! IC !! OC !! Motor<br>Ctrl !! Timers
 +
! QEI !! UART !! SPI !! I2C !! CAN !! Codec
 +
|-
 +
| 33FJ256GP506 || 6.11 || 40
 +
| 256 || 16 || 0
 +
| 53 || 18 || 8 || 8 || 0 || 9x16bit<br>4x32bit
 +
| 0 || 2 || 2 || 2 || 1 || 1
 +
|-  
 +
| 33FJ128GP206 || 4.62 || 40
 +
| 128 || 8 || 0
 +
| 53 || 18 || 8 || 8 || 0 || 9x16bit<br>4x32bit
 +
| 0 || 2 || 2 || 1 || 0 || 1
 +
|-
 +
| 33FJ128GP306 || 4.81 || 40
 +
| 128 || 16 || 0
 +
| 53 || 18 || 8 || 8 || 0 || 9x16bit<br>4x32bit
 +
| 0 || 2 || 2 || 2 || 0 || 1
 +
|-
 +
| 33FJ128GP706 || 5.49 || 40
 +
| 128 || 16 || 0
 +
| 53 || 18 || 8 || 8 || 0 || 9x16bit<br>4x32bit
 +
| 0 || 2 || 2 || 2 || 2 || 1
 +
|-
 +
| 33FJ128MC506 || 4.97 || 40
 +
| 128 || 8 || 0
 +
| 53 || 16 || 8 || 8 || 8 || 9x16bit<br>4x32bit
 +
| 1 || 2 || 2 || 2 || 1 || 0
 +
|-
 +
| 33FJ128MC706 || 5.38 || 40
 +
| 128 || 16 || 0
 +
| 53 || 16 || 8 || 8 || 8 || 9x16bit<br>4x32bit
 +
| 1 || 2 || 2 || 2 || 1 || 0
 +
|-
 +
|}
 +
<nowiki>*</nowiki>For reference only, subject to change
  
-<a href=http://ipoo.org/42tb/> buy carisoprodol </a>
+
===Forums===
-<a href=http://ipoo.org/576z/> buy cialis </a>
+
*[http://forum.microchip.com/ Microchip]: Official forum by Microchip
-<a href=http://ipoo.org/0u4g/> buy fioricet </a>
+
**See MPLAB ICD 2, MPLAB IDE, MPLAB C30 Compiler, ASM30, Link30 forum, dsPIC30F Topics, dsPic33 topics
-<a href=http://ipoo.org/4scg/> buy hydrocodone </a>
+
*[http://www.htsoft.com/forum/all/ubbthreads.php/Cat/0/C/6 HI-TECH Software Forum]: Discussion on dsPICC, a C compiler developed by HI-TECH
-<a href=http://ipoo.org/0f1v/> buy levitra </a>
+
*[http://sourceforge.net/forum/forum.php?forum_id=382005 FreeRTOS Real Time Kernel]: Open Discussion and Support on FreeRTOS
-<a href=http://ipoo.org/09c8/> buy phentermine </a>
+
*[http://www.nabble.com/MicroControllers---GNUPIC-f2057.html Nabble]: MicroControllers - GNUPIC
-<a href=http://ipoo.org/6b5h/> buy propecia </a>
 
-<a href=http://ipoo.org/83iy/> buy soma </a>
 
-<a href=http://ipoo.org/8ba0/> buy tramadol </a>
 
-<a href=http://ipoo.org/97lt/> buy ultram </a>
 
-<a href=http://ipoo.org/3ug7/> buy viagra </a>
 
-<a href=http://ipoo.org/1kmw/> buy xanax </a>
 
.............................................................
 
Popular blogs:
 
  
-<a href=http://agiovanni.blogspot.com/> Aria Giovanni </a>
+
===References===
-<a href=http://vipveronicaz.blogspot.com/> Veronica Zemanova </a>
+
*dsPIC33F
-<a href=http://vipjjensen.blogspot.com//> Jelena Jensen </a>
+
**[http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2573 dsPIC33F Family Reference Manual Sections]
....................................................................................
+
**[http://ww1.microchip.com/downloads/en/DeviceDoc/70286C.pdf dsPIC33FJXXXGPX06/X08/X10 Data Sheet]
Last changed: 18.02.2007
+
**[http://ww1.microchip.com/downloads/en/DeviceDoc/80306E.pdf dsPIC33FJXXXGPX06/X08/X10 Rev. A2/A3/A4 Silicon Errata]
 +
**[http://ww1.microchip.com/downloads/en/DeviceDoc/70152G.pdf Flash Programming Specification]
 +
*ICD2 Programmer
 +
**[http://ww1.microchip.com/downloads/en/DeviceDoc/51331C.pdf ICD2 User's Guide]
 +
*MPLAB
 +
**[http://ww1.microchip.com/downloads/en/DeviceDoc/51519B.pdf MPLAB IDE User's Guide]
 +
*C30 Compiler
 +
**[http://ww1.microchip.com/downloads/en/DeviceDoc/C30_Users_Guide_51284e.pdf MPLAB C30 C Compiler User's Guide]: Contains commands for using pic30-elf-gcc
 +
**[http://ww1.microchip.com/downloads/en/DeviceDoc/16bit_Language_Tool_Libraries_51456c.pdf 16-bit Language Tools Libraries]: Contains summaries and examples of using DSP libraries, standard C libraries and device libraries
 +
**[http://ww1.microchip.com/downloads/en/DeviceDoc/Asm30_Link_Util_51317e.pdf MPLAB ASM30, MPLAB LINK30 and Utilities User's Guide]
  
Hey dudes, check out this sweet site I found, I wasn't sure if it was real at first, but it is! I tried it out and these penis surgery alternative awesome!!!
+
===Code Examples===
Check out the special discounts they have too, I got a real good deal.
+
*[http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1408 Microchip Example Codes for dsPic]
 
Later!
 
 
More info on the site: [url=http://www.orderpenisextender.com/]alternative to penis surgery[/url]  
 
 
P.S. Sorry for posting in ""edit"" category. Please move my topic to an appropriate forum.
 
  
  Cool site.Very good!!!
+
===Related Development===
..............................................................
+
*[[Ethernet Module]]
  The following links are to pages containing information
+
*[[Modulation Plugin]]
about most popular onliine casinos:
 
  
- <a href=http://pokerstars.hut2.ru/>poker star</a>
 
- <a href=http://partypoker.hut2.ru/>party poker</a>
 
- <a href=http://onlinepoker.hut2.ru/>online poker</a>
 
- <a href=http://casinobonus.hut2.ru/>casino bonus</a>
 
- <a href=http://bestcasino.hut2.ru/>best casino</a>
 
- <a href=http://virt-casino.hut2.ru/>virtual casino</a>
 
- <a href=http://internetcas.hut2.ru/>internet casino</a>
 
- <a href=http://blackjackcas.hut2.ru/>black jack card</a>
 
- <a href=http://casblackjack.hut2.ru/>casino black jack</a>
 
- <a href=http://onlcasbonus.hut2.ru/>online casino bonus</a>
 
..............................................................
 
  The following links are to pages containing information
 
about most popular drugs:
 
  
- <a href=http://somapill.hut2.ru/> soma </a>
+
==Programming Methods==
- <a href=http://ultrampill.hut2.ru/> ultram </a>
+
*There are 2 programming methods: In-Circuit Serial Programming (ICSP) and Run-Time Self-Programming (RTSP)
- <a href=http://fioricet.hut2.ru/> fioricet </a>
+
*ICSP allows the devices to be programmed after being placed in a circuit board.
- <a href=http://buy-cialis.hut2.ru/> buy cialis </a>
+
*RTSP allows the devices to be programmed when an embedded program is already in operation.
- <a href=http://viagrabuy.hut2.ru/> buy viagra </a>
 
- <a href=http://buylevitra2.hut2.ru/> buy levitra </a>
 
- <a href=http://carisoprodol.hut2.ru/> carisoprodol </a>
 
- <a href=http://phenter-mine.hut2.ru/> phentermine </a>
 
- <a href=http://tramadonline.hut2.ru/> tramadol online </a>
 
- <a href=http://bxanaxonline.hut2.ru/> buy xanax online </a>
 
- <a href=http://buypropecia.hut2.ru/> buy propecia </a>
 
- <a href=http://buyhydrocod.hut2.ru/> buy hydrocodone </a>
 
- <a href=http://cuturl.com?newviagra/> buy viagra</a>
 
- <a href=http://cuturl.com?newphentermine/> buy phentermine </a>
 
- <a href=http://cuturl.com?newtramadol/> buy tramadol </a>
 
- <a href=http://cuturl.com?propecia/> buy propecia </a>
 
  
-<a href=http://ipoo.org/42tb/> buy carisoprodol </a>
+
===ICSP: External Programmer (ICD2)===
-<a href=http://ipoo.org/576z/> buy cialis </a>
+
*Two types of ICSP are available: '''ICSP''' and '''Enhanced ICSP'''. Both of them require setting MCLR# to V<sub>IHH</sub> (9V – 13.25V).
-<a href=http://ipoo.org/0u4g/> buy fioricet </a>
+
*Standard ICSP
-<a href=http://ipoo.org/4scg/> buy hydrocodone </a>
+
**Use external programmer (e.g. MPLAB<sup>®</sup> ICD 2, MPLAB<sup>®</sup> PM3 or PRO MATE<sup>®</sup> II) only.
-<a href=http://ipoo.org/0f1v/> buy levitra </a>
+
**Required low-level programming to erase, program and verify the chip.
-<a href=http://ipoo.org/09c8/> buy phentermine </a>
+
**Slower, because codes are serially executed.
-<a href=http://ipoo.org/6b5h/> buy propecia </a>
 
-<a href=http://ipoo.org/83iy/> buy soma </a>
 
-<a href=http://ipoo.org/8ba0/> buy tramadol </a>
 
-<a href=http://ipoo.org/97lt/> buy ultram </a>
 
-<a href=http://ipoo.org/3ug7/> buy viagra </a>
 
-<a href=http://ipoo.org/1kmw/> buy xanax </a>
 
.............................................................
 
Popular blogs:
 
  
-<a href=http://agiovanni.blogspot.com/> Aria Giovanni </a>
+
*Enhanced ICSP
-<a href=http://vipveronicaz.blogspot.com/> Veronica Zemanova </a>
+
**Use external programmer and '''Programming Executive''' (PE).
-<a href=http://vipjjensen.blogspot.com//> Jelena Jensen </a>
+
**PE is stored in the on-chip memory.
....................................................................................
+
**PE allows faster programming.
Last changed: 18.02.2007
+
**PE can be downloaded to the chip by external programmer using the standard ICSP method.
 +
**PE contains a small command set to erase, program and verify the chip, avoiding the need of low-level programming.
  
==Bootloader Development==
+
====Hardware Interface====
 
+
{| border="1" cellspacing="0" cellpadding="5"
===Concepts===
+
|+ Pin Used by ICSP
*Programming with ICSP is useful when the target board is produced in batch. The producer can download a program even when the chip is on the target board.
+
! Pin Label !! Function !! Pin Number
*However, ICSP requires an external programmer.
+
|-
*To allow the user to change the program after production but without the need of an external programmer, bootloader becomes useful.
+
| MCLR# || Programming Enable|| 7
*Bootloader is a small program installed via ICSP. Everytime the device is reset, the bootloader is run first. The bootloader first detects the default serial channel whether the user wishes to download a new program to the device. If so, the bootloader will pause there, and wait for the user to download the hex file from the PC. The hex file is written to the device via RTSP instructions in the bootloader. If a new download is not necessary, the bootloader redirects to the previously installed user's program.
+
|-
*The disadvantage of bootloaders is that they consume some of the memory of the device.
+
| V<sub>DD</sub> || Power Supply || 10, 26, 38, 57
 +
|-
 +
| V<sub>SS</sub> || Ground || 9, 25, 41, 56
 +
|-
 +
| PGC || Serial Clock || 17
 +
|-
 +
| PGD || Serial Data || 18
 +
|-
 +
|}
  
  
 
{| border="1" cellspacing="0" cellpadding="5"
 
{| border="1" cellspacing="0" cellpadding="5"
|+ Table 7.1 Free bootloaders for dsPIC
+
|+ Available Programmers in the Market
! Developer
+
! Product Name
! Source
+
! Interface with PC
! Platform
+
! Interface with Device
! User Guide
+
! *Price (US)
 
! Remarks
 
! Remarks
|- valign="top"
+
|-  
| [http://www.ingenia-cat.com/index.php?lang=en ingenia]
+
| [http://direct.www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010046&part=DV164005 MPLAB<sup>®</sup> ICD 2]
| [http://www.ingenia-cat.com/download/iBL.s Assembly]
+
| USB or RS232
| [http://www.ingenia-cat.com/download/ingeniadsPICbootloader1.1.zip Windows]
+
| [http://www.microchip.com/Microchip.WWW.SecureSoftwareList/secsoftwaredownload.aspx?device=en010046&lang=en&ReturnURL=http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010046&part=DV164005# 6-PIN RJ-12 connector]
| [http://www.ingenia-cat.com/reference/pdf/iBL.UG.V1.2.pdf pdf]
+
| $159.99
|  
+
| -
*Works for all dsPIC supporting RTSP
+
|-
*Auto baudrate detection
+
| [http://www.sureelectronics.net Clone Microchip ICD2] (Now Using)
*Use about 1.15% of the flash memory space (0xAFFF-0xAE00)/(0xAFFF-0x0100)
+
| USB
*Development of Linux platform is underway
+
| 6-pin flat cables
*Modification of code for dsPIC30F5011 is successful
+
| $52.35
|-valign="top"
+
| Do not work with new MPLAB versions (works for 7.50), communication to MPLAB may sometime hang (see [http://www.sureelectronics.net/pdfs/DB-DP003.pdf manual])
| [http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm Tiny]
 
| [http://www.etc.ugal.ro/cchiculita/software/tinybld191.zip Assembly]
 
| Windows
 
| [http://www.etc.ugal.ro/cchiculita/software/tinybldusage.htm Web]
 
|  
 
*By default, only supports 601X, 601X, 401X, 2010
 
*Smaller code size than ingenia, but not as easy to modify
 
|-valign="top"
 
| [http://www.via.si/software/dsPIC_bootloader/ Elektronika]
 
| [http://www.via.si/software/dsPIC_bootloader/data/ Hex]
 
| Windows
 
| [http://www.via.si/software/dsPIC_bootloader/data/README.txt txt]
 
|
 
*Only works for dsPIC30F6014 serial port UART2 at baudrate 57600
 
 
|-
 
|-
 
|}
 
|}
 +
<nowiki>*</nowiki>For reference only (exclude shipping), subject to change
  
===dsPicBootloader===
 
  
*The bootloader developed by ingenia is open source and it has been modified (see below) to suit our development using dsPic30f5011.
+
{| border="1" cellspacing="0" cellpadding="5"
*The bootloader (hereafter called dsPicBootloader) employs the following settings:
+
|+ DIY ICD 2 Programmer Circuit
# Use U2ART channel
+
! Source !! Schematic !! PIC16F877A Bootloader
# Use FRC, PLL16
+
|-
# For 5011, the bootloader is located between 0x00AE00 to 0x00AFFE (512bytes). Refer to C:\Program Files\Ingenia\ingeniadsPICbootloader\ibl_dspiclist.xml after installing the GUI interface.
+
| [http://membres.lycos.fr/silicium31/Electronique/PIC/FreeIcdEnglish.htm Patrick Touzet]
*Changes made to [http://www.ingenia-cat.com/download/iBL.s assembly code] includes:
+
| [http://membres.lycos.fr/silicium31/Electronique/PIC/ICD2%20V1.3.pdf Yes]
1. including p30f5011.gld and p30f5011.inc
+
| [http://membres.lycos.fr/silicium31/Electronique/PIC/ICD2_FW.zip HEX]
        .include "p30f5011.inc"
+
|-
2. changing the config code of UART #0x8420 -> #0x8020
+
| [http://www.nebadje.org/doku.php?id=neblab:icd2clone Nebadje]
        ; Uart init
+
| [http://people.ee.ethz.ch/~jbiveron/nebadje/ICD2_DOC.pdf Yes]
        mov '''#0x8020''', W0          ; W0 = 0x8020 -> 1000 0000 0010 0000b
+
| [http://people.ee.ethz.ch/~jbiveron/nebadje/ICD2_FW.zip Zip]
        mov W0, U2MODE            ; Enable UART, AutoBaud and 8N1
+
|-
        clr U2STA
+
|}
3. changing the start address 0xAE00 - 0x0100 = 0AD00
 
          .equ CRC, W4
 
          .equ ACK, 0x55
 
          .equ NACK, 0xFF
 
          .equ USER_ADDRESS, 0x0100
 
          .equ START_ADDRESS, '''0xAD00'''                ; Relative to 0x0100
 
4. using Internal FRC and PLL16
 
        config __FOSC, CSW_FSCM_OFF & '''FRC_PLL16''' ;Turn off clock switching and
 
                                          ;fail-safe clock monitoring and
 
                                            ;use the Internal Clock as the
 
                                          ;system clock
 
5. disabling MCLR (optional)
 
        config __FBORPOR, PBOR_ON & BORV_27 & PWRT_16 & '''MCLR_DIS'''
 
                                            ;Set Brown-out Reset voltage and
 
                                            ;and set Power-up Timer to 16msecs
 
6. changing all the related registers of U1ART to U2ART, all U1XXX => U2XXX
 
        '''U2MODE, U2STA, U2BRG, U2RXREG, U2TXREG'''
 
7. changing all the related registers of IC1 to IC2, all IC1XXX => IC2XXX
 
        '''IC2CON, #IC2IF, #IC2IE'''
 
  
===dsPicProgrammer (Java-based Multi-Platformed)===
 
*Ingenia developed a programmer (PC-side) that works only in Windows environment. The project for Linux environment is currently suspended.
 
*A simple programmer (hereafter called dsPicProgrammer) written in Java based on the library developed by [http://www.rxtx.org/ RXTX] has been developed here. The programmer supports both Linux and Windows environments, and may be used as a substitution for the official programmer developed by ingenia.
 
*The programmer has the following specification and limitations:
 
#Use baud rate of 57600bps (Not selectable).
 
#Only program dsPic30f5011 devices (Developers may change the source code for your devices).
 
#Protection against overwriting bootloader codes on devices.
 
#Dectection if application program does not have its reset() at address 0x100.
 
  
===Special Consideration===
+
====Software Interface====
*The bootloader assumes that the user program starts at address 0x100. This is usually the case, but there are always exceptions.
+
*The program can be written and compiled in an Integrated Development Environment (IDE) using either Assembly or C. The complied codes are then loaded to the device through the external programmer.
*To ensure that the user program always starts at address 0x100, you can create a customized linker script and customized reset() function as follows:
 
:*Copy and modify the file named "crt0.s" from the directory "C:\Program Files\Microchip\MPLAB C30\src\pic30" to the project directory and include it.
 
    .section .reset, code      //previously .section .libc, code
 
:*Copy and modify the linkerscript for the device (e.g. p30f5011.gld) to the project directory and include it.
 
  .text __CODE_BASE :
 
  {
 
      *(.reset);              //<-insert this line here
 
      *(.handle);
 
      *(.libc) *(.libm) *(.libdsp);  /* keep together in this order */
 
      *(.lib*);
 
      *(.text);
 
  } >program
 
  
===Downloads===
 
 
{| border="1" cellspacing="0" cellpadding="5"
 
{| border="1" cellspacing="0" cellpadding="5"
|+ Table 7.2 dsPicBootloader and dsPicProgrammer for dsPIC30f5011
+
|+ Summary of IDE
! Program
+
! Product Name !! Features !! OS !! Price (US$)
! Site 1
+
|-  
! Site 2
+
| [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&part=SW007002 MPLAB<sup>®</sup> IDE]
! Remarks
+
| Assembler Only
|- valign="top"
+
| Windows
| dsPicBootloader
+
| Free
| [http://chungyan5.no-ip.org/websvn/listing.php click]
+
|-
| [http://www.opencircuits.com/images/e/ed/DsPicBootloader.zip click]
+
| [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010065&part=SW006012 MPLAB<sup>®</sup> C30]
| Under "dsPicBootloader/", download ingenia.s and compile yourself
+
| Assembler and C-Compiler
|-valign="top"
+
| Windows
| dsPicProgrammer
+
| $895.00 (Free student version<sup>1</sup>)
| [http://chungyan5.no-ip.org/websvn/listing.php click]
 
| [http://www.opencircuits.com/images/1/13/DsPicProgrammer.zip click]
 
| Under "dsPicProgrammer/", dowload dsPicProgrammer.jar<br><br>Alternatively, if you want to compile yourself or modify the source code, download <br>COMDataHandler.java, COMPortManager.java, Pic5011Prog.java, Pic5011Protocol.java, <br>and WriteBuffer.java under "dsPicProgrammer/" '''plus''' RdFileIntelHex.java under <br>"IntelHexPaser/tags/0.02.00/".<br>You should also install RXTX on your local machine as recommended in the readme file.
 
 
|-
 
|-
 +
| [http://piklab.sourceforge.net/ Piklab]
 +
| Assembler and C-Compiler
 +
| Linux
 +
| Free
 
|}
 
|}
 +
# Full-featured for the first 60 days. After 60 days, some code optimization functions are disabled. The compiler will continue to function after 60 days, but code size may increase.
  
===Communication Protocol===
+
===RTSP: COM Port (Bootloader)===
* Communication Protocol is reviewed in [http://www.ingenia-cat.com/reference/pdf/iBL.UG.V1.2.pdf ingenia bootloader user's guide] section 2.1.3. The following summarises the key steps on the PC side (Refer also to section 2.2.2).
+
*RTSP works in normal voltage (MCLR# no need to raise to V<sub>IHH</sub>).
* Transmission is conducted in 8N1, i.e. 8-bit, no parity, 1 stop-bit
+
*No literature has mentioned the incorporation of Programming Executive (PE). Presumably, since Enhanced ICSP needs to set MCLR# to V<sub>IHH</sub>, RTSP cannot use PE.
* '''Stage 1: User's configuation'''
+
*Refer to [[DsPIC30F_5011_Development_Board#Bootloader_Development | bootloader section]].
**Select a baudrate
 
**Select a COM port channel
 
* '''Stage 2: Autobaud rate detection and version control'''
 
**Continuously sending a character "U" [0x55] via COM port
 
**Continuously waiting for an acknowledgment character "U", [ACK] = [0x55]
 
**Send command character [0x03]
 
**Receive 3 characters 1) Major Version 2) Minor Version 3) Acknowledgment [0x55]
 
**Prints the version number [Major.Minor] (e.g. 1.1) on screen.
 
* '''Stage 3: Loading and writing the program'''
 
**Load the user hex file, check integrity.
 
**Start loading file using:
 
***Read command character [0x01] + 24-bit address [High][Medium][Low]
 
***Receive 4-byte data [High][Medium][Low][ACK]
 
***Write command character [0x02] + 24-bit address [High][Medium][Low]+ Number of bytes [N] + [data 0] + [data 1] + ... + [data N-1] + [CRC]=(INTEL HEX8 Checksum - Sum modulo 256)
 
***Receive [ACK] or [NACK] = [0xFF]
 
***Note: Writing is in row mode access (i.e. erase and write a whole row, each row has 32 instructions, or 96 bytes because each instruction has 24 bits)
 
::# Ensure the initial address of writing match an initial row position,
 
::# Send the data corresponding to the whole row.
 
  
  
==USB-RS232 Bridge==
+
==Development Environment==
  
*As USB ports are becoming more and more common, COM ports and Parallel ports may be redundant in the next few years. This section explore the possibilities of programming the target board through a USB port.
+
===Windows===
*There are two options:
 
#Use an external USB/RS232 adaptor, the driver will emulate a virtual COM port, such as [http://www.prolific.com.tw/eng/downloads.asp?ID=31 Prolific] and [http://www.ftdichip.com/Drivers/VCP.htm FDTI]. Ingenia has tested its bootloader with some USB-232 manufacturers (silabs, FTDI, etc..). However, the programming failed with our Prolific adapter. Application program may use [http://java.sun.com/products/javacomm/ JavaComm API] (javax.comm) and/or [http://www.rxtx.org/ RXTX] to drive the COM port.
 
#Modified the bootloader program on PC to support USB communication. e.g. using [http://jusb.sourceforge.net/ jUSB] and [http://javax-usb.org/ JSR-80] (javax.usb). External circuits such as PIC18F4550 and MAX232 are required.
 
  
    |--User's App.--|-------Device Manager------|-------USB-RS232 Interface------|---dsPIC---|
+
[[Image:PIC_setup_win.JPG]]
  Option 1:
 
    +-------------+  +----------+  +----------+  +---+  +------------+  +-----+  +--------+
 
    | Application |--| JavaComm |--| Virtual  |==|USB|--|    FDTI    |--|RS232|==| Target |
 
    |  Program  |  |  RXTX    |  | COM Port |  +---+  | Circuitary |  +-----+  | Board  |
 
    +-------------+  +----------+  +----------+        +------------+          +--------+
 
  Option 2:
 
    +-------------+          +--------+          +---+  +------------+  +-----+  +--------+
 
    | Application |----------| JSR-80 |==========|USB|--| PIC18F4550 |--|RS232|==| Target |
 
    |  Program  |          |  jUSB  |          +---+  |  MAX232  |  +-----+  | Board  |
 
    +-------------+          +--------+                +------------+          +--------+
 
  
*Currently, when RXTX is incorporated with JavaComm API, operating systems supported include Linux, Windows, Mac OS, Solaris and other operating systems. On the other hand, jUSB and JSR-80 only works for linux.
+
*C-Compiler, Assembler and Linker are under GNU license.
 +
**MPLAB C30 C Compiler (*.c -> *.s)
 +
**MPLAB ASM30 Assembler (*.s -> *.o)
 +
**MPLAB LINK30 Linker (*.o -> *.bin)
  
===FDTI Chipset===
+
*PA optimizer, simulator, runtime libraries, header files, include files, and linker scripts are not covered by GNU. Reference is [http://direct.forum.microchip.com/tm.aspx?m=107208 here].
*FT232RL communicates with PC via USB to provide 1 UART channel.
 
*Datasheet can be downloaded [http://www.ftdichip.com/Documents/DataSheets/DS_FT232R.pdf here].
 
**Refer to Fig. 11 (Page 19) for Bus Powered Configuration.
 
**Refer to Fig. 16 (Page 24) for for UART TTL-level Receive [RXD -> 1], Transmit [TXD -> 4], Transmit Enable [CBUS2/TXDEN -> 3]. Omit Receive Enable [CBUS3/PWREN#] and use [CBUS2/TXDEN -> 2]
 
**Refer to Fig. 15 (Page 23) for LED Configuration: [CBUS0/TXLED#] and [CBUS1/RXLED#]
 
*Virtual COM Port Drivers can be downloaded [http://www.ftdichip.com/Drivers/VCP.htm here].
 
  
 +
*Microchip has integrated ASM30, LINK30, assembly header files, linker scripts in MPLAB IDE, which is free for download.
 +
*MPLAB C30 costs US$895. A 60-day free student version is also available. After 60-days, the optimizer is automatically disabled, while other tools can still function properly.
  
==Programming the Device==
+
*C-libraries contained in C30 includes (Refer to [http://ww1.microchip.com/downloads/en/DeviceDoc/16bit_Language_Tool_Libraries_51456c.pdf 16-Bit Language Tools Libraries] from Microchip).
  
===Requirements===
 
*Hardware
 
#PC with COM port (Windows XP Installed for MPLAB)
 
#ICD2 Programmer
 
#Target Board
 
#5V Power Supply
 
  
*Software
 
#[http://ww1.microchip.com/downloads/en/DeviceDoc/MP750.zip MPLAB IDE v7.50 or higher]
 
#[http://chungyan5.no-ip.org/websvn/listing.php dsPicProgrammer] ('''dsPicProgrammer.jar''')
 
#[http://users.frii.com/jarvi/rxtx/download.html RXTX driver]
 
 
*Files
 
#[http://chungyan5.no-ip.org/websvn/listing.php dsPicBootloader] ('''ingenia.hex'''). Original assembly code by ingenia can be downloaded from [http://www.ingenia-cat.com/download/iBL.s here].
 
#Application hex file (e.g. '''app.hex''')
 
 
===Loading Bootloader (Once only)===
 
 
{|border="1" cellspacing="0" cellpadding="5"
 
{|border="1" cellspacing="0" cellpadding="5"
|+ Table 9.1 Loading Bootloader
+
|+ C Libraries in MPLAB C30
! Step !! Remarks
+
! Library !! Directory <br>(\\Microchip\MPLAB C30) !! Major functions
 
|-valign="top"
 
|-valign="top"
| Install [http://ww1.microchip.com/downloads/en/DeviceDoc/MP750.zip MPLAB IDE] ||  
+
| DSP Library <br>(e.g. libdsp-coff.a)
*Do '''NOT''' connect ICD 2 (via USB) to PC
+
| \lib <br> \src\dsp <br> \support\h
*Execute '''MPLAB vX.XX Install.exe'''
+
| Vector, Matrix, Filter, etc.
 
|-valign="top"
 
|-valign="top"
| Install USB Driver ||
+
| 16-Bit Peripheral Libraries
*Follow the instruction in (C:\Program Files\Microchip\MPLAB IDE\ICD2\Drivers\Ddicd2.htm)
+
| \lib <br> \src\peripheral <br> \support\h
 +
| ADC12, IOPort, UART, I<sup>2</sup>C, etc.
 
|-valign="top"
 
|-valign="top"
| Select Target Chip ||
+
| Standard C Libraries <br>(e.g. libc-coff.a, libm-coff.a, libpic-coff.a)
*Run MPLAB IDE on PC
+
| \lib <br> \src\libm <br> \include
*Select: Configure>Select Devices...
+
| stdio.h, time.h, float.h, math.h,
*Choose dsPIC30F5011
 
 
|-valign="top"
 
|-valign="top"
| Target <-> ICD 2  ||
+
| MPLAB C30 Built-in Functions
*Use six pin cable. Beware of the pin assignments. Only pin 1 - 5 should be used.
+
| none
*Place Jumper on target board (if any). The Jumper connects target V<sub>cc</sub> to ICD 2.
+
| _buildin_addab, _buildin_add, _buildinmpy, etc
*Do '''NOT''' power-up the target.
+
|-
 +
|}
 +
 
 +
===Linux===
 +
 
 +
[[Image:PIC_setup_linux.JPG]]
 +
 
 +
*C Compiler, Assembler and Linker are under GNU license.
 +
**The code can be downloaded from Microchip at [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en023073 here].
 +
**Current MPLAB ASM30 Assembler: v2.04
 +
**Current MPLAB C30 Compiler: v2.04
 +
*'''Important Note''': Only the compiler is free. The header files and library are owned by Microchip.
 +
 
 +
{|border="1" cellspacing="0" cellpadding="5"
 +
|+ Pic30 C-Compiler Toolchain Templates for Conversion to Debian-based systems
 +
! Toolchain Source !! Instruction !! Remarks
 
|-valign="top"
 
|-valign="top"
| ICD 2 <-> PC ||
+
| [http://www.baycom.org/~tom/dspic/ v2.00]
*Plug-in ICD 2 to PC via USB cable
+
| Download pic30-gcc-2.00-1.i386.rpm and pic30-binutils-2.00-1.i386.rpm.<br>Convert to deb files.
*Power-up the target.
+
| Stable<br>Now using
*Select: Programmer>Select Programmer>MPLAB ICD 2
 
*If this is the first time the ICD 2 is connected to PC, MPLAB IDE will automatically download the required OS to ICD 2, wait until it has finished
 
*If you have not connected and powered up the target, you might see Warnings on invalid device IDs, and/or running self tests.
 
*See results of self test if necessary: Programmer>Settings, Status Tab. Refer to [http://ww1.microchip.com/downloads/en/DeviceDoc/51331B.pdf ICD2 User's Guide] Chapter 7.
 
 
|-valign="top"
 
|-valign="top"
| Load Bootloader ||
+
| [http://www.nabble.com/Debian-templates-for-dsPIC-build-toolchain-2.05-td7886279.html v2.05]
*Select: File>Import...
+
| Reference to example below, but use 2.05 files
*Select '''ingenia.hex'''
+
| Can compile<br>Stable but not heavily tested
 
|-valign="top"
 
|-valign="top"
| Start Programming ||
+
| [http://www.nabble.com/Debian-templates-for-dsPIC-build-toolchain-3.01-tf4308624.html v3.01]
*Select: Programmer>Program
+
| Follow example below
 +
| Can compile<br>Unstable (sometime produce segmentation fault)
 
|-valign="top"
 
|-valign="top"
| Finishing ||
+
| [http://www.nabble.com/Debian-Template-Patches-for-C30-v3.10-i386-td17534084.html v3.10]
*Power-down the Taget
+
| Reference to example below, but use 3.10 files
*Select: Programmer>Select Programmer>None
+
| Cannot compile yet (segmentation fault)
*Unplug USB cable
 
 
|-
 
|-
 
|}
 
|}
 +
====Conversion Example====
 +
*Pre-install these packages: dpkg-dev, debhelper, bison, flex, sysutils, gcc-3.3, fakeroot
 +
**cmd: '''sudo apt-get install dpkg-dev debhelper bison flex sysutils gcc-3.3 fakeroot'''
 +
*Download and unzip template: '''pic30-3.01.tar.bz2'''
 +
*Download assembler: '''mplabalc30v3_01_A.tar.gz'''. Save under /pic30-3.01/pic30-binutils-3.01/upstream/
 +
*Download c-compiler: '''mplabc30v3_01_A.tgz'''. Save under /pic30-3.01/pic30-gcc-3.01/upstream/
 +
*Install MPLAB_C30_v3_01-StudentEdition under Windows
 +
*Copy directories /include, /lib, /support, and /bin/c30_device.info to pic30-3.01/pic30-support-3.01/upstream/
 +
*Pack pic30-binutils into deb file
 +
**goto /pic30-3.01/pic30-binutils-3.01/
 +
**type cmd: '''dpkg-buildpackage -rfakeroot -b'''
 +
*Install pic30-binutils_3.01-1_i386.deb
 +
**type cmd: '''sudo dpkg -i pic30-binutils_3.01-1_i386.deb'''
 +
*Pack pic30-gcc-3.01 into deb file
 +
**goto /pic30-3.01/pic30-gcc-3.01/
 +
**type cmd: '''dpkg-buildpackage -rfakeroot -b'''
 +
*Install pic30-gcc_3.01-1_i386.deb
 +
**type cmd: '''sudo dpkg -i pic30-gcc_3.01-1_i386.deb'''
 +
*Pack support files into deb file
 +
**goto /pic30-3.01/pic30-support-3.01/
 +
**type cmd: '''dpkg-buildpackage -rfakeroot -b'''
 +
*Install pic30-support_3.01-1_all.deb
 +
**type cmd: '''sudo dpkg -i pic30-support_3.01-1_all.deb'''
 +
*After installation, locations of
 +
**C-Header (*.h): /usr/pic30-elf/include
 +
**Libraries (*.a): /usr/pic30-elf/lib
 +
**Assembly header (*.inc): /usr/share/pic30-support/inc
 +
**Linkerscript (*.gld): /usr/share/pic30-support/gld
 +
 +
===Burning Program Codes to Target Board===
 +
#Use 'dspicprg and dspicdmp' utilities developed by [http://homerreid.ath.cx/misc/dspicprg/ Homer Reid] to burn hex code (*.hex) to devices. See Reference [http://forum.microchip.com/tm.aspx?m=94243 here]. Through serial port only?
 +
#Use [http://piklab.sourceforge.net/ Piklab IDE]. Details on file format not known.
 +
#Use [http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&part=SW007002 MPLAB IDE] to burn hex code (*.hex) to devices.
 +
 +
===Code Optimization===
 +
*Below is a comparsion between different optimization levels for the project including drivers for 2 projects.
  
===Loading Application===
 
 
{|border="1" cellspacing="0" cellpadding="5"
 
{|border="1" cellspacing="0" cellpadding="5"
|+ Table 9.2 Loading Application File
+
|+ Comparison between differnt optimization levels
! Step !! Remarks
+
! Optimization !! Description !! Project 1<br>Code Size<br>(byte) !! Project 1<br>Data Usage<br>(byte) !! Project 2<br>Code Size<br>(byte) !! Project 2<br>Data Usage<br>(byte)
 
|-valign="top"
 
|-valign="top"
| Install RXTX ||
+
| O0
*For Windows User:
+
| No optimization<br>Fastest Compilation
**copy RXTXcomm.jar to \jre\lib\ext (under java)
+
| 6222 (9%) || 178 (4%) || 26,037 (38%) || 710 (17%)
**copy rxtxSerial.dll to \jre\bin
 
*For Linux User:
 
**copy RXTXcomm.jar to /jre/lib/ext (under java)
 
**copy librxtxSerial.so to /jre/lib/[machine type] (i386 for instance)
 
 
|-valign="top"
 
|-valign="top"
| Connect target board ||
+
| O1
*For Windows User:
+
| Optimize<br> Tries to reduce code size and execution time.
**connect to COM1 (or other useable port)
+
| 4473 (6%) || 178 (4%) || 22,290 (32%) || 710 (17%)
*For Linux User:
 
**connect to ttyS0 (or other useable port)
 
 
|-valign="top"
 
|-valign="top"
| Open a console window ||
+
| O2
*In Windows, Start>Run, and type cmd.
+
| Optimize even more<br> Performs nearly all supported optimizations <br>that do not involve a space-speed trade-off. <br>Increases both compilation time and the <br>performance of the generated code.
 +
| 4422 (6%) || 178 (4%) || 21,993 (32%) || 710 (17%)
 
|-valign="top"
 
|-valign="top"
| Start Programming ||
+
| O3
*Change to the directory containing dsPicProgrammer.jar
+
| Optimize yet more. <br>O3 turns on all optimizations specified by O2 <br>and also turns on the inline-functions option.
*Execute dsPicProgrammer.jar
+
| 4485 (6%) || 178 (4%) || 22,176 (32%) || 710 (17%)
**For Windows User: java -jar dsPicProgrammer.jar COMi Y:\foo2\app.hex
 
**For Linux User: java -jar dsPicProgrammer.jar /dev/ttySi Y:/foo2/app.hex
 
*Power-up target board
 
 
|-valign="top"
 
|-valign="top"
| Finishing ||
+
| Os
*Power-down target board
+
| Optimize for size. <br>Os enables all O2 optimizations that do not <br>typically increase code size. It also performs <br>further optimizations designed to reduce code <br>size.
*Disconnect from COM port
+
| 4356 (6%) || 178 (4%) || 21,885 (32%) || 710 (17%)
 
|-
 
|-
 
|}
 
|}
  
  
==Remote Access==
+
==[[freertos_posix Development | Driver Development]]==
*At the moment, local devices (e.g. EEPROM, ADC, DAC, etc.) can only be accessed locally through POSIX functions such as open(), read(), write(), ioctl().
+
*Description on developing drivers with POSIX API
*However, a client may need to access these devices on a remote server. This section reviews the background and gives some ideas on its possible implementation.
+
 
 +
 
 +
==[[Bootloader Development]]==
 +
*Description on concepts and development on bootloader
 +
*Description on dsPicProgrammer to download firmware via bootloader
  
===Requirements===
 
*A remote file access protocol, to transfer "files" (i.e. device's data) such as:
 
#[http://en.wikipedia.org/wiki/FTP File Transfer Protocol] (FTP): Required files are copied from sever to client for manipulation
 
#[http://en.wikipedia.org/wiki/Remote_Shell Remote Shell] (RSH): Required files are copied from sever to client for manipulation
 
#[http://en.wikipedia.org/wiki/Network_File_System_%28Sun%29 Network File System] (NFS): Required files are manipulated on sever
 
*An API to access files using a selected protocol, such as:
 
#[http://www.die.net/doc/linux/man/man2/lam_rfposix.2.html lam_rfposix]: A POSIX-like remote file service for Local Area Multicomputer
 
#API employed by VxWorks: [http://en.wikipedia.org/wiki/VxWorks VxWorks] is a Unix-like real-time operating system, commonly used for embedded systems.
 
  
===API Reference for VxWorks===
+
==[[Programming the Device]]==
*Reference:
+
*Description on how to use dsPicProgrammer to download firmware to dspic
**[http://www.windriver.com/vxworks/ VxWorks Official Website]
 
**[http://www-cdfonline.fnal.gov/daq/commercial/ OS Libraries API Reference]
 
*Related Libraies
 
**netDrv (netDrv.h): an API using FTP or RSH
 
**nfsDrv (nfsDrv.h): an API using NFS
 
  
  
==To Do List==
+
[[category:projects]]
#Construct examples codes for using DSP library
 
#Construct examples codes for using Build-in library
 
#GUI Interface for Benchtop boards
 

Latest revision as of 06:30, 16 October 2012

This project aims to provide the development tools for building a multi-purpose MCU board. Description is based on Microchip dsPic33FJ256GP506 (was dsPic30F5011), but information provided in this wiki may give useful directions for developing similar embedded systems with different platforms.

Introduction

Features of dsPic33FJ256GP506

  • 3.0 to 3.3 V
  • Up to 40 MIPs
  • Maximum current sink/source for I/O pins: 4 mA
  • 16-bit arithmetics
  • DSP Instruction Set
  • Dual programming techniques: ICSP and RTSP
  • Memory
    • 256 KB flash (86K instructions)
    • 16 KB RAM (incl. 2 KB DMA RAM)
    • No EEPROM
  • Communications ports
    • UART
    • I2C: up to 1 Mbit/s
    • SPI
  • ADC
  • 10-bit A/D, 1.1 Msps
  • 12-bit A/D, 500 ksps
  • No DAC (PWMs only)
  • Pin-to-pin compatible with other dsPICs
Comparison between different dsPICs
dsPic *Price
US$
MIPs Flash
(kB)
RAM
(kB)
EEPROM
(kB)
I/O ADC
12-bit
IC OC Motor
Ctrl
Timers QEI UART SPI I2C CAN Codec
33FJ256GP506 6.11 40 256 16 0 53 18 8 8 0 9x16bit
4x32bit
0 2 2 2 1 1
33FJ128GP206 4.62 40 128 8 0 53 18 8 8 0 9x16bit
4x32bit
0 2 2 1 0 1
33FJ128GP306 4.81 40 128 16 0 53 18 8 8 0 9x16bit
4x32bit
0 2 2 2 0 1
33FJ128GP706 5.49 40 128 16 0 53 18 8 8 0 9x16bit
4x32bit
0 2 2 2 2 1
33FJ128MC506 4.97 40 128 8 0 53 16 8 8 8 9x16bit
4x32bit
1 2 2 2 1 0
33FJ128MC706 5.38 40 128 16 0 53 16 8 8 8 9x16bit
4x32bit
1 2 2 2 1 0

*For reference only, subject to change

Forums

  • Microchip: Official forum by Microchip
    • See MPLAB ICD 2, MPLAB IDE, MPLAB C30 Compiler, ASM30, Link30 forum, dsPIC30F Topics, dsPic33 topics
  • HI-TECH Software Forum: Discussion on dsPICC, a C compiler developed by HI-TECH
  • FreeRTOS Real Time Kernel: Open Discussion and Support on FreeRTOS
  • Nabble: MicroControllers - GNUPIC

References

Code Examples

Related Development


Programming Methods

  • There are 2 programming methods: In-Circuit Serial Programming (ICSP) and Run-Time Self-Programming (RTSP)
  • ICSP allows the devices to be programmed after being placed in a circuit board.
  • RTSP allows the devices to be programmed when an embedded program is already in operation.

ICSP: External Programmer (ICD2)

  • Two types of ICSP are available: ICSP and Enhanced ICSP. Both of them require setting MCLR# to VIHH (9V – 13.25V).
  • Standard ICSP
    • Use external programmer (e.g. MPLAB® ICD 2, MPLAB® PM3 or PRO MATE® II) only.
    • Required low-level programming to erase, program and verify the chip.
    • Slower, because codes are serially executed.
  • Enhanced ICSP
    • Use external programmer and Programming Executive (PE).
    • PE is stored in the on-chip memory.
    • PE allows faster programming.
    • PE can be downloaded to the chip by external programmer using the standard ICSP method.
    • PE contains a small command set to erase, program and verify the chip, avoiding the need of low-level programming.

Hardware Interface

Pin Used by ICSP
Pin Label Function Pin Number
MCLR# Programming Enable 7
VDD Power Supply 10, 26, 38, 57
VSS Ground 9, 25, 41, 56
PGC Serial Clock 17
PGD Serial Data 18


Available Programmers in the Market
Product Name Interface with PC Interface with Device *Price (US) Remarks
MPLAB® ICD 2 USB or RS232 6-PIN RJ-12 connector $159.99 -
Clone Microchip ICD2 (Now Using) USB 6-pin flat cables $52.35 Do not work with new MPLAB versions (works for 7.50), communication to MPLAB may sometime hang (see manual)

*For reference only (exclude shipping), subject to change


DIY ICD 2 Programmer Circuit
Source Schematic PIC16F877A Bootloader
Patrick Touzet Yes HEX
Nebadje Yes Zip


Software Interface

  • The program can be written and compiled in an Integrated Development Environment (IDE) using either Assembly or C. The complied codes are then loaded to the device through the external programmer.
Summary of IDE
Product Name Features OS Price (US$)
MPLAB® IDE Assembler Only Windows Free
MPLAB® C30 Assembler and C-Compiler Windows $895.00 (Free student version1)
Piklab Assembler and C-Compiler Linux Free
  1. Full-featured for the first 60 days. After 60 days, some code optimization functions are disabled. The compiler will continue to function after 60 days, but code size may increase.

RTSP: COM Port (Bootloader)

  • RTSP works in normal voltage (MCLR# no need to raise to VIHH).
  • No literature has mentioned the incorporation of Programming Executive (PE). Presumably, since Enhanced ICSP needs to set MCLR# to VIHH, RTSP cannot use PE.
  • Refer to bootloader section.


Development Environment

Windows

PIC setup win.JPG

  • C-Compiler, Assembler and Linker are under GNU license.
    • MPLAB C30 C Compiler (*.c -> *.s)
    • MPLAB ASM30 Assembler (*.s -> *.o)
    • MPLAB LINK30 Linker (*.o -> *.bin)
  • PA optimizer, simulator, runtime libraries, header files, include files, and linker scripts are not covered by GNU. Reference is here.
  • Microchip has integrated ASM30, LINK30, assembly header files, linker scripts in MPLAB IDE, which is free for download.
  • MPLAB C30 costs US$895. A 60-day free student version is also available. After 60-days, the optimizer is automatically disabled, while other tools can still function properly.


C Libraries in MPLAB C30
Library Directory
(\\Microchip\MPLAB C30)
Major functions
DSP Library
(e.g. libdsp-coff.a)
\lib
\src\dsp
\support\h
Vector, Matrix, Filter, etc.
16-Bit Peripheral Libraries \lib
\src\peripheral
\support\h
ADC12, IOPort, UART, I2C, etc.
Standard C Libraries
(e.g. libc-coff.a, libm-coff.a, libpic-coff.a)
\lib
\src\libm
\include
stdio.h, time.h, float.h, math.h,
MPLAB C30 Built-in Functions none _buildin_addab, _buildin_add, _buildinmpy, etc

Linux

PIC setup linux.JPG

  • C Compiler, Assembler and Linker are under GNU license.
    • The code can be downloaded from Microchip at here.
    • Current MPLAB ASM30 Assembler: v2.04
    • Current MPLAB C30 Compiler: v2.04
  • Important Note: Only the compiler is free. The header files and library are owned by Microchip.
Pic30 C-Compiler Toolchain Templates for Conversion to Debian-based systems
Toolchain Source Instruction Remarks
v2.00 Download pic30-gcc-2.00-1.i386.rpm and pic30-binutils-2.00-1.i386.rpm.
Convert to deb files.
Stable
Now using
v2.05 Reference to example below, but use 2.05 files Can compile
Stable but not heavily tested
v3.01 Follow example below Can compile
Unstable (sometime produce segmentation fault)
v3.10 Reference to example below, but use 3.10 files Cannot compile yet (segmentation fault)

Conversion Example

  • Pre-install these packages: dpkg-dev, debhelper, bison, flex, sysutils, gcc-3.3, fakeroot
    • cmd: sudo apt-get install dpkg-dev debhelper bison flex sysutils gcc-3.3 fakeroot
  • Download and unzip template: pic30-3.01.tar.bz2
  • Download assembler: mplabalc30v3_01_A.tar.gz. Save under /pic30-3.01/pic30-binutils-3.01/upstream/
  • Download c-compiler: mplabc30v3_01_A.tgz. Save under /pic30-3.01/pic30-gcc-3.01/upstream/
  • Install MPLAB_C30_v3_01-StudentEdition under Windows
  • Copy directories /include, /lib, /support, and /bin/c30_device.info to pic30-3.01/pic30-support-3.01/upstream/
  • Pack pic30-binutils into deb file
    • goto /pic30-3.01/pic30-binutils-3.01/
    • type cmd: dpkg-buildpackage -rfakeroot -b
  • Install pic30-binutils_3.01-1_i386.deb
    • type cmd: sudo dpkg -i pic30-binutils_3.01-1_i386.deb
  • Pack pic30-gcc-3.01 into deb file
    • goto /pic30-3.01/pic30-gcc-3.01/
    • type cmd: dpkg-buildpackage -rfakeroot -b
  • Install pic30-gcc_3.01-1_i386.deb
    • type cmd: sudo dpkg -i pic30-gcc_3.01-1_i386.deb
  • Pack support files into deb file
    • goto /pic30-3.01/pic30-support-3.01/
    • type cmd: dpkg-buildpackage -rfakeroot -b
  • Install pic30-support_3.01-1_all.deb
    • type cmd: sudo dpkg -i pic30-support_3.01-1_all.deb
  • After installation, locations of
    • C-Header (*.h): /usr/pic30-elf/include
    • Libraries (*.a): /usr/pic30-elf/lib
    • Assembly header (*.inc): /usr/share/pic30-support/inc
    • Linkerscript (*.gld): /usr/share/pic30-support/gld

Burning Program Codes to Target Board

  1. Use 'dspicprg and dspicdmp' utilities developed by Homer Reid to burn hex code (*.hex) to devices. See Reference here. Through serial port only?
  2. Use Piklab IDE. Details on file format not known.
  3. Use MPLAB IDE to burn hex code (*.hex) to devices.

Code Optimization

  • Below is a comparsion between different optimization levels for the project including drivers for 2 projects.
Comparison between differnt optimization levels
Optimization Description Project 1
Code Size
(byte)
Project 1
Data Usage
(byte)
Project 2
Code Size
(byte)
Project 2
Data Usage
(byte)
O0 No optimization
Fastest Compilation
6222 (9%) 178 (4%) 26,037 (38%) 710 (17%)
O1 Optimize
Tries to reduce code size and execution time.
4473 (6%) 178 (4%) 22,290 (32%) 710 (17%)
O2 Optimize even more
Performs nearly all supported optimizations
that do not involve a space-speed trade-off.
Increases both compilation time and the
performance of the generated code.
4422 (6%) 178 (4%) 21,993 (32%) 710 (17%)
O3 Optimize yet more.
O3 turns on all optimizations specified by O2
and also turns on the inline-functions option.
4485 (6%) 178 (4%) 22,176 (32%) 710 (17%)
Os Optimize for size.
Os enables all O2 optimizations that do not
typically increase code size. It also performs
further optimizations designed to reduce code
size.
4356 (6%) 178 (4%) 21,885 (32%) 710 (17%)


Driver Development

  • Description on developing drivers with POSIX API


Bootloader Development

  • Description on concepts and development on bootloader
  • Description on dsPicProgrammer to download firmware via bootloader


Programming the Device

  • Description on how to use dsPicProgrammer to download firmware to dspic