Difference between revisions of "DsPIC30F 5011 Development Board"

From OpenCircuits
Jump to navigation Jump to search
m (Reverted edits by ColeenRosales (Talk) to last revision by Russ hensel)
 
(30 intermediate revisions by 10 users not shown)
Line 1: Line 1:
 +
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.
 +
 
==Introduction==
 
==Introduction==
  
===Features of dsPIC30F5011===
+
===Features of dsPic33FJ256GP506===
*2.5 to 5V
+
*3.0 to 3.3 V
*Up to 30MIPs
+
*Up to 40 MIPs
*High current/sink source I/O pins: 25mA
+
*Maximum current sink/source for I/O pins: 4 mA
 +
*16-bit arithmetics
 
*DSP Instruction Set
 
*DSP Instruction Set
 
*Dual programming techniques: ICSP and RTSP
 
*Dual programming techniques: ICSP and RTSP
*UART: up to 2 modules
+
*Memory
*I<sup>2</sup>C: up to 1Mbps
+
**256&nbsp;KB flash (86K instructions)
 +
**16&nbsp;KB RAM (incl. 2&nbsp;KB DMA RAM)
 +
**No EEPROM
 +
*Communications ports
 +
**UART
 +
**I<sup>2</sup>C: up to 1&nbsp;Mbit/s
 +
**SPI
 +
*ADC
 
*10-bit A/D, 1.1 Msps
 
*10-bit A/D, 1.1 Msps
*12-bit A/D, 200 ksps
+
*12-bit A/D, 500 ksps
*44K flash (66Kb), 4Kb RAM, 1Kb EEPROM
+
*No DAC (PWMs only)
*No DAC
 
 
*Pin-to-pin compatible with other dsPICs
 
*Pin-to-pin compatible with other dsPICs
 
{| border="1" cellspacing="0" cellpadding="5"
 
{| border="1" cellspacing="0" cellpadding="5"
|+ Table 1.1 Comparison with Compatible dsPICs
+
|+ Comparison between different dsPICs
! dsPic !! Price<br>US$ !! MIPs
+
! dsPic !! *Price<br>US$ !! MIPs
 
! Flash<br>(kB)!! RAM<br>(kB) !! EEPROM<br>(kB)
 
! Flash<br>(kB)!! RAM<br>(kB) !! EEPROM<br>(kB)
 
! I/O !! ADC<br>12-bit !! IC !! OC !! Motor<br>Ctrl !! Timers
 
! I/O !! ADC<br>12-bit !! IC !! OC !! Motor<br>Ctrl !! Timers
 
! QEI !! UART !! SPI !! I2C !! CAN !! Codec
 
! QEI !! UART !! SPI !! I2C !! CAN !! Codec
|-
 
| 30F5011 || 5.91 || 30
 
| 66 || 4 || 1
 
| 52 || 16 || 8 || 8 || 0 || 5x16bit<br>2x32bit
 
| 0 || 2 || 2 || 1 || 2 || 1
 
 
|-
 
|-
| 30F6011A || 7.73 || 30
+
| 33FJ256GP506 || 6.11 || 40
| 132 || 6 || 2
+
| 256 || 16 || 0
| 52 || 16 || 8 || 8 || 0 || 5x16bit<br>2x32bit
+
| 53 || 18 || 8 || 8 || 0 || 9x16bit<br>4x32bit
| 0 || 2 || 2 || 1 || 2 || 0
+
| 0 || 2 || 2 || 2 || 1 || 1
|-
 
| 30F6012A || 7.85 || 30
 
| 144 || 8 || 4
 
| 52 || 16 || 8 || 8 || 0 || 5x16bit<br>2x32bit
 
| 0 || 2 || 2 || 1 || 2 || 1
 
 
|-  
 
|-  
 
| 33FJ128GP206 || 4.62 || 40
 
| 33FJ128GP206 || 4.62 || 40
Line 60: Line 59:
 
| 53 || 16 || 8 || 8 || 8 || 9x16bit<br>4x32bit
 
| 53 || 16 || 8 || 8 || 8 || 9x16bit<br>4x32bit
 
| 1 || 2 || 2 || 2 || 1 || 0
 
| 1 || 2 || 2 || 2 || 1 || 0
|-
 
| 33FJ256GP506 || 6.11 || 40
 
| 256 || 16 || 0
 
| 53 || 18 || 8 || 8 || 0 || 9x16bit<br>4x32bit
 
| 0 || 2 || 2 || 2 || 1 || 1
 
 
|-
 
|-
 
|}
 
|}
+
<nowiki>*</nowiki>For reference only, subject to change
===Web Page===
 
*[http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2529&param=en024856 Microchip Official Website]
 
  
===Forum===
+
===Forums===
*[http://direct.forum.microchip.com/default.aspx Microchip]: Official forum by Microchip
+
*[http://forum.microchip.com/ Microchip]: Official forum by Microchip
**[http://direct.forum.microchip.com/tt.aspx?forumid=49 MPLAB ICD 2]: Subforum on ICD 2 programmer
+
**See MPLAB ICD 2, MPLAB IDE, MPLAB C30 Compiler, ASM30, Link30 forum, dsPIC30F Topics, dsPic33 topics
**[http://direct.forum.microchip.com/tt.aspx?forumid=57 MPLAB IDE]: Subforum on IDE
 
**[http://direct.forum.microchip.com/tt.aspx?forumid=101 MPLAB C30 Compiler, ASM30, Link30 forum]: Subforum on C compiler. Refer to [http://ww1.microchip.com/downloads/en/DeviceDoc/C30_Users_Guide_51284e.pdf MPLAB C30 C Compiler User's Guide] Chapter 3
 
**[http://direct.forum.microchip.com/tt.aspx?forumid=153 dsPIC30F Topics]: Subformum on dsPIC30F
 
*[http://www.gnupic.org/ GNUPIC]: Discussion on PIC in Linux Systems
 
**[http://www.linuxhacker.org/cgi-bin/ezmlm-cgi?1:dds:5443#b Debian]
 
 
*[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
 
*[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
*[http://piclist.com/techref/piclist/index.htm PICList]: Discussion on older PIC systems (not dsPIC)
 
*[http://groups.google.com/group/pickit-devel PicKit]: Discussion on PICkit/PICkit 2 programmers
 
 
*[http://sourceforge.net/forum/forum.php?forum_id=382005 FreeRTOS Real Time Kernel]: Open Discussion and Support on FreeRTOS
 
*[http://sourceforge.net/forum/forum.php?forum_id=382005 FreeRTOS Real Time Kernel]: Open Discussion and Support on FreeRTOS
 
*[http://www.nabble.com/MicroControllers---GNUPIC-f2057.html Nabble]: MicroControllers - GNUPIC
 
*[http://www.nabble.com/MicroControllers---GNUPIC-f2057.html Nabble]: MicroControllers - GNUPIC
  
 
===References===
 
===References===
*dsPIC30F
 
**[http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2574 dsPIC30F Family Reference Manual Sections]: Contains detailed descriptions on dsPIC30F register definitions and example codes
 
**[http://ww1.microchip.com/downloads/en/DeviceDoc/80169E.pdf dsPIC30F Family Reference Manual Errata (Use with revision 70046B only)]
 
**[http://ww1.microchip.com/downloads/en/DeviceDoc/70116F.pdf dsPIC30F5011, dsPIC30F5013 Data Sheet]
 
**[http://ww1.microchip.com/downloads/en/DeviceDoc/80210e.pdf dsPIC30F5011/5013 Rev. A1/A2 Silicon Errata]
 
**[http://ww1.microchip.com/downloads/en/DeviceDoc/80223D.pdf dsPIC30F5011/5013 Rev. A3 Silicon Errata]
 
**[http://ww1.microchip.com/downloads/en/DeviceDoc/70102G.pdf Flash Programming Specification]
 
**[http://ww1.microchip.com/downloads/en/DeviceDoc/70157B.pdf dsPIC30F Programmer's Reference Manual]
 
**[http://ww1.microchip.com/downloads/en/DeviceDoc/80170a.pdf dsPIC30F Programmer's Reference Manual Errata (use with revision DS70030E only)]
 
 
 
*dsPIC33F
 
*dsPIC33F
 
**[http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2573 dsPIC33F Family Reference Manual Sections]
 
**[http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2573 dsPIC33F Family Reference Manual Sections]
**[http://ww1.microchip.com/downloads/en/DeviceDoc/70165E.pdf dsPIC33F Family Data Sheet]
+
**[http://ww1.microchip.com/downloads/en/DeviceDoc/70286C.pdf dsPIC33FJXXXGPX06/X08/X10 Data Sheet]
**[http://ww1.microchip.com/downloads/en/DeviceDoc/80279B.pdf dsPIC33F Rev. A2 Silicon Errata]
+
**[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/80306A.pdf dsPIC33FJXXXGPX06/X08/X10 Rev. A2 Silicon Errata]
+
**[http://ww1.microchip.com/downloads/en/DeviceDoc/70152G.pdf Flash Programming Specification]
**[http://ww1.microchip.com/downloads/en/DeviceDoc/70152C.pdf Flash Programming Specification]
 
**[http://ww1.microchip.com/downloads/en/DeviceDoc/70172A.pdf dsPIC30F to dsPIC33F Conversion Guidelines]
 
 
*ICD2 Programmer
 
*ICD2 Programmer
**[http://ww1.microchip.com/downloads/en/DeviceDoc/51331B.pdf ICD2 User's Guide]
+
**[http://ww1.microchip.com/downloads/en/DeviceDoc/51331C.pdf ICD2 User's Guide]
 
*MPLAB
 
*MPLAB
 
**[http://ww1.microchip.com/downloads/en/DeviceDoc/51519B.pdf MPLAB IDE User's Guide]
 
**[http://ww1.microchip.com/downloads/en/DeviceDoc/51519B.pdf MPLAB IDE User's Guide]
Line 111: Line 84:
 
**[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/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]
 
**[http://ww1.microchip.com/downloads/en/DeviceDoc/Asm30_Link_Util_51317e.pdf MPLAB ASM30, MPLAB LINK30 and Utilities User's Guide]
**[http://ww1.microchip.com/downloads/en/DeviceDoc/51322d.pdf dsPIC30F Language Tools Quick Reference Card]
 
  
 
===Code Examples===
 
===Code Examples===
Line 117: Line 89:
  
 
===Related Development===
 
===Related Development===
*[http://www.opencircuits.com/Ethernet_Module Ethernet Module]
+
*[[Ethernet Module]]
*[http://www.opencircuits.com/Modulation_Plugin Modulation Plugin]
+
*[[Modulation Plugin]]
*[http://chungyan5.no-ip.org/wiki/index.php/UI GUI Development]
 
  
  
Line 133: Line 104:
 
**Required low-level programming to erase, program and verify the chip.
 
**Required low-level programming to erase, program and verify the chip.
 
**Slower, because codes are serially executed.
 
**Slower, because codes are serially executed.
**Program memory can be erased using ''Normal-Voltage'' (4.5 – 5.5V) or ''Low-Voltage'' (2.5V – 4.5V).
 
  
 
*Enhanced ICSP
 
*Enhanced ICSP
Line 165: Line 135:
 
! Interface with PC
 
! Interface with PC
 
! Interface with Device
 
! Interface with Device
! Price (US)
+
! *Price (US)
! Postage (US)
+
! Remarks
! Total (US)
 
 
|-  
 
|-  
 
| [http://direct.www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010046&part=DV164005 MPLAB<sup>®</sup> ICD 2]
 
| [http://direct.www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010046&part=DV164005 MPLAB<sup>®</sup> ICD 2]
Line 173: Line 142:
 
| [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.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]
 
| $159.99
 
| $159.99
| -
 
 
| -
 
| -
 
|-
 
|-
| [http://www.etekronics.com/product_info.php?cPath=24&products_id=48  Full Speed USB Microchip ICD2<br> Debugger and Programmer]
+
| [http://www.sureelectronics.net Clone Microchip ICD2] (Now Using)
| USB
 
| 6-PIN ICSP connector<br>6-PIN RJ-12 connector
 
| $72.00
 
| $12.00
 
| $84.00
 
|-
 
| [http://www.etekronics.com/product_info.php?cPath=24&products_id=47 Mini Microchip Compatible ICD2<br> Debugger and Programmer]
 
| RS232
 
| 6-PIN ICSP connector<br>6-PIN RJ-12 connector
 
| $45.00
 
| $10.00
 
| $55.00
 
|-
 
| [http://www.inexglobal.com/microcontroller.php ICDX30]
 
| RS232
 
| 6-pin RJ-11
 
| $51.00
 
| $47.46
 
| $98.46
 
|-
 
| *[http://www.sure-electronics.net Clone Microchip ICD2] (Now Using)
 
 
| USB
 
| USB
 
| 6-pin flat cables
 
| 6-pin flat cables
| $30.00
+
| $52.35
| $12.00
+
| 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])
| $42.00
 
 
|-
 
|-
 
|}
 
|}
 +
<nowiki>*</nowiki>For reference only (exclude shipping), subject to change
  
  
Line 220: Line 167:
 
|-
 
|-
 
|}
 
|}
 +
  
 
====Software Interface====
 
====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.
 
*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.
 
  
 
{| border="1" cellspacing="0" cellpadding="5"
 
{| border="1" cellspacing="0" cellpadding="5"
Line 249: Line 196:
 
*RTSP works in normal voltage (MCLR# no need to raise to V<sub>IHH</sub>).
 
*RTSP works in normal voltage (MCLR# no need to raise to V<sub>IHH</sub>).
 
*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.
 
*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.
*Refer to [http://www.opencircuits.com/DsPIC30F_5011_Development_Board#Bootloader_Development bootloader section].
+
*Refer to [[DsPIC30F_5011_Development_Board#Bootloader_Development | bootloader section]].
 
 
 
 
==IC Requirements==
 
{|border="1" cellspacing="0" cellpadding="5"
 
|+ IC Requirements
 
! Part No. !! Description
 
! Min Temp !! Max Temp !! Min Volt !! Max Volt !! Typ Cur !! Max Cur
 
|-valign="top"
 
| [http://ww1.microchip.com/downloads/en/DeviceDoc/70116F.pdf dsPIC30F5011-30I/PT] || uP
 
| -40<sup>o</sup>C || 85<sup>o</sup>C
 
| 2.5V <sup>[1]</sup>|| 5.5V
 
|  145mA  || 217mA
 
|-
 
| [http://datasheets.maxim-ic.com/en/ds/MAX3222-MAX3241.pdf MAX3232ESE] || RS232 driver
 
| -40<sup>o</sup>C || 85<sup>o</sup>C
 
| 3.0V || 5.5V
 
| 0.3mA || 1.0mA
 
|-
 
| [http://www.national.com/ds.cgi/DS/DS3695.pdf DS3695N] || RS485 driver
 
| -40<sup>o</sup>C || 85<sup>o</sup>C
 
| 4.75V || 5.25V
 
| 42mA || 60mA
 
|-
 
| [http://focus.ti.com/lit/ds/symlink/dac6574.pdf DAC6574IDGS] || 10-bit Quad-DAC I<sup>2</sup>C
 
| -40<sup>o</sup>C || 105<sup>o</sup>C
 
| 2.7V || 5.5V
 
| 0.6mA || 0.9mA
 
|-
 
| [http://www.semiconductors.philips.com/acrobat/datasheets/74HC_HCT14_3.pdf 74HC14D] || Quad-Schmitt Trigger
 
| -40<sup>o</sup>C || 125<sup>o</sup>C
 
| 2.0V || 6.0V
 
| || 0.02mA
 
|-
 
| '''Overall''' ||
 
| '''-40<sup>o</sup>C''' || '''85<sup>o</sup>C'''
 
| '''4.75V''' || '''5.25V'''
 
| || '''<300mA <sup>[2]</sup>'''
 
|-
 
| [http://ww1.microchip.com/downloads/en/DeviceDoc/70165E.pdf dsPIC33FJ128GP306-I/PT] || uP
 
| -40<sup>o</sup>C || 85<sup>o</sup>C
 
| 3.0V <sup>[1]</sup>|| 3.6V
 
| 74mA  || 250mA
 
|-
 
| [http://www.analog.com/UploadedFiles/Data_Sheets/ADM3485E.pdf ADM3485EARZ] || RS485 driver
 
| -40<sup>o</sup>C || 85<sup>o</sup>C
 
| 3.0V || 3.6V
 
| 1.1mA || 2.2mA
 
|-
 
| [http://ww1.microchip.com/downloads/en/DeviceDoc/21203N.pdf 24LC256-I/SN] || 256kBits I2C EEPROM
 
| -40<sup>o</sup>C || 85<sup>o</sup>C
 
| 2.5V || 5.5V
 
| 400uA || 3mA
 
|-
 
| [http://www.national.com/ds.cgi/LM/LM3940.pdf LM3940IMP-3.3] || 5V-3.3V Regulator
 
| -40<sup>o</sup>C || 125<sup>o</sup>C
 
| 5.0V || 7.5V
 
| 10mA || 250mA
 
|-
 
|}
 
#Minimum voltage measured is 3.3V (with 2 LEDs blinking) running at 30MHz.
 
#Measured current at 5V is 180mA (with 2 LEDs blinking only)
 
  
  
Line 327: Line 213:
  
 
*Microchip has integrated ASM30, LINK30, assembly header files, linker scripts in MPLAB IDE, which is free for download.
 
*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. Refer to Table 2.4.
+
*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 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).
 
*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).
Line 340: Line 226:
 
| Vector, Matrix, Filter, etc.
 
| Vector, Matrix, Filter, etc.
 
|-valign="top"
 
|-valign="top"
| 16-Bit Peripheral Libraries <br>(e.g. libp30F5011-coff.a)
+
| 16-Bit Peripheral Libraries
 
| \lib <br> \src\peripheral <br> \support\h
 
| \lib <br> \src\peripheral <br> \support\h
 
| ADC12, IOPort, UART, I<sup>2</sup>C, etc.
 
| ADC12, IOPort, UART, I<sup>2</sup>C, etc.
Line 362: Line 248:
 
**Current MPLAB ASM30 Assembler: v2.04
 
**Current MPLAB ASM30 Assembler: v2.04
 
**Current MPLAB C30 Compiler: v2.04
 
**Current MPLAB C30 Compiler: v2.04
 +
*'''Important Note''': Only the compiler is free. The header files and library are owned by Microchip.
  
*[http://gcc.gnu.org/ml/gcc/2005-02/msg01144.html John Steele Scott] has made templates that can be readily used by Debian-based systems.
+
{|border="1" cellspacing="0" cellpadding="5"
*For v1.32, the necessary conversion to *.deb has been done already at [http://noel.feld.cvut.cz/dspic/ here].
+
|+ Pic30 C-Compiler Toolchain Templates for Conversion to Debian-based systems
**Download '''pic30-1.32-debian.tar.bz2''' for Template v1.32.
+
! Toolchain Source !! Instruction !! Remarks
**Download '''pic30-binutils_1.32-1_i386.deb''' for the assember.
+
|-valign="top"
**Download '''pic30-gcc_1.32-1_i386.deb''' for the compiler.
+
| [http://www.baycom.org/~tom/dspic/ v2.00]
*For v2.00
+
| Download pic30-gcc-2.00-1.i386.rpm and pic30-binutils-2.00-1.i386.rpm.<br>Convert to deb files.
**goto http://www.baycom.org/~tom/dspic/
+
| Stable<br>Now using
**download pic30-gcc-2.00-1.i386.rpm and pic30-binutils-2.00-1.i386.rpm
+
|-valign="top"
**convert to deb files
+
| [http://www.nabble.com/Debian-templates-for-dsPIC-build-toolchain-2.05-td7886279.html v2.05]
**install these two deb files
+
| Reference to example below, but use 2.05 files
*For v3.01, convert the Toolchain following instructions at [http://www.nabble.com/Debian-templates-for-dsPIC-build-toolchain-3.01-tf4308624.html here]
+
| Can compile<br>Stable but not heavily tested
**Pre-install these packages: dpkg-dev, debhelper, bison, flex, sysutils, gcc-3.3, fakeroot
+
|-valign="top"
***cmd: '''sudo apt-get install dpkg-dev debhelper bison flex sysutils gcc-3.3 fakeroot'''
+
| [http://www.nabble.com/Debian-templates-for-dsPIC-build-toolchain-3.01-tf4308624.html v3.01]
**Download and unzip template: '''pic30-3.01.tar.bz2'''
+
| Follow example below
**Download assembler: '''mplabalc30v3_01_A.tar.gz'''. Save under /pic30-3.01/pic30-binutils-3.01/upstream/
+
| Can compile<br>Unstable (sometime produce segmentation fault)
**Download c-compiler: '''mplabc30v3_01_A.tgz'''. Save under /pic30-3.01/pic30-gcc-3.01/upstream/
+
|-valign="top"
**Install MPLAB_C30_v3_01-StudentEdition under Windows
+
| [http://www.nabble.com/Debian-Template-Patches-for-C30-v3.10-i386-td17534084.html v3.10]
**Copy directories /include, /lib, /support, and /bin/c30_device.info to pic30-3.01/pic30-support-3.01/upstream/
+
| Reference to example below, but use 3.10 files
**Pack pic30-binutils into deb file
+
| Cannot compile yet (segmentation fault)
***goto /pic30-3.01/pic30-binutils-3.01/
+
|-
***type cmd: '''dpkg-buildpackage -rfakeroot -b'''
+
|}
**Pack pic30-gcc-3.01 into deb file
+
====Conversion Example====
***goto /pic30-3.01/pic30-gcc-3.01/
+
*Pre-install these packages: dpkg-dev, debhelper, bison, flex, sysutils, gcc-3.3, fakeroot
***type cmd: '''dpkg-buildpackage -rfakeroot -b'''
+
**cmd: '''sudo apt-get install dpkg-dev debhelper bison flex sysutils gcc-3.3 fakeroot'''
**Pack pic30-gcc-3.01 into deb file
+
*Download and unzip template: '''pic30-3.01.tar.bz2'''
***goto /pic30-3.01/pic30-support-3.01/
+
*Download assembler: '''mplabalc30v3_01_A.tar.gz'''. Save under /pic30-3.01/pic30-binutils-3.01/upstream/
***type cmd: '''dpkg-buildpackage -rfakeroot -b'''
+
*Download c-compiler: '''mplabc30v3_01_A.tgz'''. Save under /pic30-3.01/pic30-gcc-3.01/upstream/
**install pic30-binutils_3.01-1_i386.deb
+
*Install MPLAB_C30_v3_01-StudentEdition under Windows
***type cmd: '''sudo dpkg -i pic30-binutils_3.01-1_i386.deb'''
+
*Copy directories /include, /lib, /support, and /bin/c30_device.info to pic30-3.01/pic30-support-3.01/upstream/
**install pic30-gcc_3.01-1_i386.deb
+
*Pack pic30-binutils into deb file
***type cmd: '''sudo dpkg -i pic30-gcc_3.01-1_i386.deb'''
+
**goto /pic30-3.01/pic30-binutils-3.01/
**install pic30-support_3.01-1_all.deb
+
**type cmd: '''dpkg-buildpackage -rfakeroot -b'''
***type cmd: '''sudo dpkg -i pic30-support_3.01-1_all.deb'''
+
*Install pic30-binutils_3.01-1_i386.deb
*'''Important Note''': Only the compiler is free. The header files and library are owned by Microchip.
+
**type cmd: '''sudo dpkg -i pic30-binutils_3.01-1_i386.deb'''
**Thomas Sailer suggested to download the Student version of C30 compiler and then build the libraries without source code. A package template for Fedora system is available [http://www.baycom.org/~tom/dspic/ here].
+
*Pack pic30-gcc-3.01 into deb file
**Instructions for filling the upstream direction is available [http://forum.microchip.com/printable.aspx?m=139360 here].
+
**goto /pic30-3.01/pic30-gcc-3.01/
**Alteratively, [https://gna.org/projects/pic30-libc/ Stephan Walter] has started a project to develop C Runtime Library for dsPIC.
+
**type cmd: '''dpkg-buildpackage -rfakeroot -b'''
***Current libraries in version 0.1.1 include: assert.h, cdefs.h, ctype.h, errno.h, inttypes.h, stdint.h, stdio.h, stdlib.h, string.h
+
*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
+
===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 '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://piklab.sourceforge.net/ Piklab IDE]. Details on file format not known.
Line 437: Line 335:
  
  
==Software Architecture==
+
==[[freertos_posix Development | Driver Development]]==
*Refer to: [http://www.opencircuits.com/Multi-purpose_Embedded_System#RTOS here]
 
 
 
==[[Programming Tips]]==
 
 
*Description on developing drivers with POSIX API
 
*Description on developing drivers with POSIX API
  
Line 446: Line 341:
 
==[[Bootloader Development]]==
 
==[[Bootloader Development]]==
 
*Description on concepts and development on bootloader
 
*Description on concepts and development on bootloader
 
+
*Description on dsPicProgrammer to download firmware via bootloader
 
 
==USB-RS232 Bridge==
 
 
 
*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.
 
*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---|
 
  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.
 
 
 
===FDTI Chipset===
 
*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].
 
  
  
Line 482: Line 348:
  
  
==Remote Access==
+
[[category:projects]]
*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().
 
*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.
 
 
 
===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===
 
*Reference:
 
**[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
 
 
 
 
 
==[[Conversion to dsPIC33F Devices]]==
 
*This section discusses the conversion required from dsPIC30F5011 to dsPIC33FJ128GP306.
 
*Refer to official document [http://ww1.microchip.com/downloads/en/DeviceDoc/70172A.pdf dsPIC30F to dsPIC33F Conversion Guidelines] (DS70172A).
 
*Note that this section does not mainly intend to introduce the new functionalities of dsPIC33F devices. It only serves the purpose to summarise the major (if not minimum) changes required to port the setup of dsPIC30 to dsPIC33 devices.
 
 
 
 
 
==Downloads==
 
{| border="1" cellspacing="0" cellpadding="5"
 
|+ Related software download links for dsPicBootloader and dsPicProgrammer
 
! Program
 
! Site
 
! Remarks
 
|- valign="top"
 
| JDK
 
| [http://java.sun.com/javase/downloads/index.jsp website]
 
| Download latest JDK
 
|- valign="top"
 
| RXTX
 
| [http://users.frii.com/jarvi/rxtx/download.html website]
 
| Download rxtx-2.1-7-bins-r2.zip or later
 
|- valign="top"
 
| dsPicBootloader
 
| [http://chungyan5.no-ip.org/vc click]
 
| Under "dsPicBootloader/", download bl_5011.s or bl_j128gp306.s
 
|-valign="top"
 
| dsPicProgrammer
 
| [http://chungyan5.no-ip.org/vc click]
 
| Under "dsPicProgrammer/", dowload dsPicProgrammer.jar<br><br>Alternatively, if you want to compile yourself or modify the source code, download <br>all source files 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.
 
|- valign="top"
 
| Ingenia's bootloader
 
| [http://www.ingenia-cat.com/en/downloads.php website]
 
| Download original ingenia's bootloader
 
|-
 
|}
 
 
 
 
 
==ToDo==
 
*dspic gcc compiler for constant problem
 
*add chip to stable voltage upon power failure or to detect low voltage, and generate interrupt for dsPic to execute shutdown routine (e.g. save important data to NVM, shutdown ethernet etc.)
 
*program the bootloader into flash under linux platform
 

Latest revision as of 07: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