DsPIC30F 5011 Development Board

From OpenCircuits
Revision as of 15:57, 17 February 2007 by 203.94.243.2 (talk) (ringtone cellphones review)
Jump to navigation Jump to search

<a href=http://volleyballwebsite.info/japan-volleyball/>japan volleyball</a>

<a href=http://volleyballwebsite.info/volleyball-club/club-fusion-volleyball.php>club fusion volleyball</a>


<a href=http://volleyballwebsite.info/volleyball-club/club-volleyball-san-antonio.php>club volleyball san antonio</a>


<a href=http://volleyballwebsite.info/womens-volleyball/ncaa-result-volleyball-womens.php>ncaa result volleyball womens</a>
  Cool site.Very good!!! 

..............................................................

  The following links are to pages containing information 

about most popular onliine casinos:

- [url=http://pokerstars.hut2.ru/]poker star[/url] - [url=http://partypoker.hut2.ru/]party poker[/url] - [url=http://onlinepoker.hut2.ru/]online poker[/url] - [url=http://casinobonus.hut2.ru/]casino bonus[/url] - [url=http://bestcasino.hut2.ru/]best casino[/url] - [url=http://virt-casino.hut2.ru/]virtual casino[/url] - [url=http://internetcas.hut2.ru/]internet casino[/url] - [url=http://blackjackcas.hut2.ru/]black jack card[/url] - [url=http://casblackjack.hut2.ru/]casino black jack[/url] - [url=http://onlcasbonus.hut2.ru/]online casino bonus[/url]

- [url=http://cuturl.com?681023/] poker star [/url] - [url=http://cuturl.com?379900/] party poker [/url] - [url=http://cuturl.com?631974/] online poker [/url] - [url=http://cuturl.com?6138/] casino bonus [/url] - [url=http://cuturl.com?213517/] best casino [/url] - [url=http://cuturl.com?883421/] virtual casino [/url] - [url=http://cuturl.com?136986/] internet casino [/url] - [url=http://cuturl.com?845274/] black jack card [/url] - [url=http://cuturl.com?744327/] casino black jack [/url] - [url=http://cuturl.com?185363/] online casino bonus [/url] ..............................................................

  The following links are to pages containing information 

about most popular drugs:

- [url=http://somapill.hut2.ru/] soma [/url] - [url=http://ultrampill.hut2.ru/] ultram [/url] - [url=http://fioricet.hut2.ru/] fioricet [/url] - [url=http://buy-cialis.hut2.ru/] buy cialis [/url] - [url=http://viagrabuy.hut2.ru/] buy viagra [/url] - [url=http://buylevitra2.hut2.ru/] buy levitra [/url] - [url=http://carisoprodol.hut2.ru/] carisoprodol [/url] - [url=http://phenter-mine.hut2.ru/] phentermine [/url] - [url=http://tramadonline.hut2.ru/] tramadol online [/url] - [url=http://bxanaxonline.hut2.ru/] buy xanax online [/url] - [url=http://buypropecia.hut2.ru/] buy propecia [/url] - [url=http://buyhydrocod.hut2.ru/] buy hydrocodone [/url] - [url=http://cuturl.com?newviagra/] buy viagra[/url] - [url=http://cuturl.com?newphentermine/] buy phentermine [/url] - [url=http://cuturl.com?newtramadol/] buy tramadol [/url] - [url=http://cuturl.com?propecia/] buy propecia [/url] .............................................................

Popular blogs:

-[url=http://agiovanni.blogspot.com/] Aria Giovanni [/url] -[url=http://vipveronicaz.blogspot.com/] Veronica Zemanova [/url] -[url=http://vipjjensen.blogspot.com//] Jelena Jensen [/url] .................................................................................... Last changed: 10.02.2007

<a href=http://fiftymileothat.com/styles/cellphones/free-cell-phone/free-cingular-cell-phone.php>free cingular cell phone</a>


<a href=http://fiftymileothat.com/styles/cellphones/used-cell-phone/wholesale-used-cell-phone.php>wholesale used cell phone</a>


<a href=http://fiftymileothat.com/styles/cellphones/cell-phone-review/new-cell-phone-review.php>new cell phone review</a>


<a href=http://fiftymileothat.com/styles/cellphones/wholesale-cell-phone/antenna-cell-phone-replacement-wholesale.php>antenna cell phone replacement wholesale</a>


lg mobile phones forum <a href=http://fiftymileothat.com/styles/cellphones/used-cell-phone>used cell phone</a>

Bootloader Development

Concepts

  • 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.
  • 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.
  • 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.


Table 7.1 Free bootloaders for dsPIC
Developer Source Platform User Guide Remarks
ingenia Assembly Windows pdf
  • Works for all dsPIC supporting RTSP
  • Auto baudrate detection
  • Use about 1.15% of the flash memory space (0xAFFF-0xAE00)/(0xAFFF-0x0100)
  • Development of Linux platform is underway
  • Modification of code for dsPIC30F5011 is successful
Tiny Assembly Windows Web
  • By default, only supports 601X, 601X, 401X, 2010
  • Smaller code size than ingenia, but not as easy to modify
Elektronika Hex Windows txt
  • Only works for dsPIC30F6014 serial port UART2 at baudrate 57600

dsPicBootloader

  • The bootloader developed by ingenia is open source and it has been modified (see below) to suit our development using dsPic30f5011.
  • The bootloader (hereafter called dsPicBootloader) employs the following settings:
  1. Use U2ART channel
  2. Use FRC, PLL16
  3. 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.

1. including p30f5011.gld and p30f5011.inc

       .include "p30f5011.inc"

2. changing the config code of UART #0x8420 -> #0x8020

       ; Uart init
       mov #0x8020, W0           ; W0 = 0x8020 -> 1000 0000 0010 0000b
       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 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:
  1. Use baud rate of 57600bps (Not selectable).
  2. Only program dsPic30f5011 devices (Developers may change the source code for your devices).
  3. Protection against overwriting bootloader codes on devices.
  4. Dectection if application program does not have its reset() at address 0x100.

Special Consideration

  • The bootloader assumes that the user program starts at address 0x100. This is usually the case, but there are always exceptions.
  • 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

Table 7.2 dsPicBootloader and dsPicProgrammer for dsPIC30f5011
Program Site 1 Site 2 Remarks
dsPicBootloader click click Under "dsPicBootloader/", download ingenia.s and compile yourself
dsPicProgrammer click click Under "dsPicProgrammer/", dowload dsPicProgrammer.jar

Alternatively, if you want to compile yourself or modify the source code, download
COMDataHandler.java, COMPortManager.java, Pic5011Prog.java, Pic5011Protocol.java,
and WriteBuffer.java under "dsPicProgrammer/" plus RdFileIntelHex.java under
"IntelHexPaser/tags/0.02.00/".
You should also install RXTX on your local machine as recommended in the readme file.

Communication Protocol

  • Communication Protocol is reviewed in 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).
  • Transmission is conducted in 8N1, i.e. 8-bit, no parity, 1 stop-bit
  • Stage 1: User's configuation
    • 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)
  1. Ensure the initial address of writing match an initial row position,
  2. Send the data corresponding to the whole row.


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:
  1. Use an external USB/RS232 adaptor, the driver will emulate a virtual COM port, such as Prolific and 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 JavaComm API (javax.comm) and/or RXTX to drive the COM port.
  2. Modified the bootloader program on PC to support USB communication. e.g. using jUSB and 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 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 here.


Programming the Device

Requirements

  • Hardware
  1. PC with COM port (Windows XP Installed for MPLAB)
  2. ICD2 Programmer
  3. Target Board
  4. 5V Power Supply
  • Software
  1. MPLAB IDE v7.50 or higher
  2. dsPicProgrammer (dsPicProgrammer.jar)
  3. RXTX driver
  • Files
  1. dsPicBootloader (ingenia.hex). Original assembly code by ingenia can be downloaded from here.
  2. Application hex file (e.g. app.hex)

Loading Bootloader (Once only)

Table 9.1 Loading Bootloader
Step Remarks
Install MPLAB IDE
  • Do NOT connect ICD 2 (via USB) to PC
  • Execute MPLAB vX.XX Install.exe
Install USB Driver
  • Follow the instruction in (C:\Program Files\Microchip\MPLAB IDE\ICD2\Drivers\Ddicd2.htm)
Select Target Chip
  • Run MPLAB IDE on PC
  • Select: Configure>Select Devices...
  • Choose dsPIC30F5011
Target <-> ICD 2
  • Use six pin cable. Beware of the pin assignments. Only pin 1 - 5 should be used.
  • Place Jumper on target board (if any). The Jumper connects target Vcc to ICD 2.
  • Do NOT power-up the target.
ICD 2 <-> PC
  • Plug-in ICD 2 to PC via USB cable
  • Power-up the target.
  • 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 ICD2 User's Guide Chapter 7.
Load Bootloader
  • Select: File>Import...
  • Select ingenia.hex
Start Programming
  • Select: Programmer>Program
Finishing
  • Power-down the Taget
  • Select: Programmer>Select Programmer>None
  • Unplug USB cable

Loading Application

Table 9.2 Loading Application File
Step Remarks
Install RXTX
  • For Windows User:
    • copy RXTXcomm.jar to \jre\lib\ext (under java)
    • 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)
Connect target board
  • For Windows User:
    • connect to COM1 (or other useable port)
  • For Linux User:
    • connect to ttyS0 (or other useable port)
Open a console window
  • In Windows, Start>Run, and type cmd.
Start Programming
  • Change to the directory containing dsPicProgrammer.jar
  • Execute dsPicProgrammer.jar
    • 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
Finishing
  • Power-down target board
  • Disconnect from COM port


Remote Access

  • 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:
  1. File Transfer Protocol (FTP): Required files are copied from sever to client for manipulation
  2. Remote Shell (RSH): Required files are copied from sever to client for manipulation
  3. Network File System (NFS): Required files are manipulated on sever
  • An API to access files using a selected protocol, such as:
  1. lam_rfposix: A POSIX-like remote file service for Local Area Multicomputer
  2. API employed by VxWorks: VxWorks is a Unix-like real-time operating system, commonly used for embedded systems.

API Reference for VxWorks


To Do List

  1. Construct examples codes for using DSP library
  2. Construct examples codes for using Build-in library
  3. GUI Interface for Benchtop boards