Documente Academic
Documente Profesional
Documente Cultură
com/DsPIC30F_5011_Development_Board
Contents
1 Introduction
1.1 Features of dsPIC30F5011
1.2 Web Page
1.3 Forum
1.4 References
2 Programming Methods
2.1 ICSP: External Programmer (ICD2)
2.1.1 Hardware Interface
2.1.2 Software Interface
2.2 RTSP: COM Port (Bootloader)
3 IC Requirements
4 Development Environment
4.1 Windows
4.2 Linux
4.3 Code Optimization
5 Software Architecture
6 Programming Tips
6.1 Memory Map for 5011
6.2 Data Location
6.3 Configuration Bits
6.4 Timer
6.4.1 Free Time Clock
6.4.2 Time Measurement
6.5 Interrupt
6.6 UART
6.6.1 Auto baud rate detection
6.6.2 Initialize UART
6.6.3 Sending and Receiving Data
6.7 I2C
6.8 ADC
6.8.1 Configuration
6.8.2 Storing ADC Data
6.8.3 Adding and Removing Channels
6.9 EEPROM
6.9.1 Seek
6.9.2 Read
6.9.3 Write
6.10 Simple PWM (Output Compare Module)
6.10.1 open()
6.10.2 ioctl()
6.10.3 write()
6.10.4 Propagration Delay
6.11 DSP Library
6.11.1 Data Types
1 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
Introduction
Features of dsPIC30F5011
2.5 to 5V
Up to 30MIPs
High current/sink source I/O pins: 25mA
DSP Instruction Set
Dual programming techniques: ICSP and RTSP
UART: up to 2 modules
I2C: up to 1Mbps
10-bit A/D, 1.1 Msps
12-bit A/D, 200 ksps
44K flash (66Kb), 4Kb RAM, 1Kb EEPROM
No DAC
Pin-to-pin compatible with other dsPICs
2 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
5x16bit
30F5011 5.91 30 66 4 1 52 16 8 8 0 0 2
2x32bit
5x16bit
30F6011A 7.73 30 132 6 2 52 16 8 8 0 0 2
2x32bit
5x16bit
30F6012A 7.85 30 144 8 4 52 16 8 8 0 0 2
2x32bit
9x16bit
33FJ128GP206 4.62 40 128 8 0 53 18 8 8 0 0 2
4x32bit
9x16bit
33FJ128GP306 4.81 40 128 16 0 53 18 8 8 0 0 2
4x32bit
9x16bit
33FJ128GP706 5.49 40 128 16 0 53 18 8 8 0 0 2
4x32bit
9x16bit
33FJ128MC506 4.97 40 128 8 0 53 16 8 8 8 1 2
4x32bit
9x16bit
33FJ128MC706 5.38 40 128 16 0 53 16 8 8 8 1 2
4x32bit
9x16bit
33FJ256GP506 6.11 40 256 16 0 53 18 8 8 0 0 2
4x32bit
Web Page
Forum
References
dsPIC30F
Family Overview (http://ww1.microchip.com/downloads/en/DeviceDoc/70043F.pdf)
Family Reference Manual (http://ww1.microchip.com/downloads/en/DeviceDoc/70046E.pdf) :
3 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
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.
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.
Program memory can be erased using Normal-Voltage (4.5 – 5.5V) or Low-Voltage (2.5V – 4.5V).
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
4 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
Product Name
MPLAB® ICD 2
(http://direct.www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010046&par
Full Speed USB Microchip ICD2
Debugger and Programmer (http://www.etekronics.com/product_info.php?cPath=24&products_id=48)
Mini Microchip Compatible ICD2
Debugger and Programmer (http://www.etekronics.com/product_info.php?cPath=24&products_id=47)
ICDX30 (http://www.inexglobal.com/microcontroller.php)
Clone Microchip ICD2 (http://www.sure-electronics.net/englishsite/icd2/icd2.htm)
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.
5 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
Product Name
MPLAB® IDE
(http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en019469&part=SW0
MPLAB® C30
(http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en010065&part=SW0
1. Full-featured for the first 60 days. After 60 days only optimization level 1 can be enabled in the compiler.
The compiler will continue to function after 60 days, but code size may increase.
2. The current version supports external programmer ICD 2, but not yet tested.
IC Requirements
Table 3.1 IC Requirements
Min Max
Part No. Description
Temp Temp
dsPIC30F5011-30I/PT uP -40oC 85o
(http://ww1.microchip.com/downloads/en/DeviceDoc/70116F.pdf)
MAX3232ESE (http://datasheets.maxim-ic.com/en/ds/MAX3222-MAX3241.pdf) RS232 driver -40oC 85o
10-bit
DAC6574DGS (http://focus.ti.com/lit/ds/symlink/dac6574.pdf) Quad-DAC -40oC 105
I2C
74HC14D Quad-Schmitt
(http://www.semiconductors.philips.com/acrobat/datasheets/74HC_HCT14_3.pdf) Trigger -40oC 125
dsPIC33FJ128GP306
(http://ww1.microchip.com/downloads/en/DeviceDoc/70165E.pdf)
uP -40oC 85o
ADM3485EARZ
RS485 driver -40oC 85o
(http://www.analog.com/UploadedFiles/Data_Sheets/ADM3485E.pdf)
6 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
Development Environment
Windows
PA optimizer, simulator, runtime libraries, header files, include files, and linker scripts are not covered by
GNU. Reference is here (http://direct.forum.microchip.com/tm.aspx?m=107208) .
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.
7 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
Linux
Important Note: Only the compiler is free. The header files and library is owned by Microchip.
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 here
(http://www.baycom.org/~tom/dspic/) .
Instructions for filling the upstream direction is available here
(http://forum.microchip.com/printable.aspx?m=139360) .
Alteratively, Stephan Walter (https://gna.org/projects/pic30-libc/) has started a project to develop C
Runtime Library for dsPIC.
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
8 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
Code Optimization
Software Architecture
9 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
+----------+-----------+---------+---------+
| local | remote | | |
+----------+-----------+ host | UI |
| data access | channel | |
| (DI,DO,AI,AO) | | |
+----------------------+---------+---------+
| Application |
| |
+------------------------------------------+
| Applications Model |
| +--------------+-----------+ |
| | GUI | CLib | |
| | +------+-----------+-------+
| | | Operating System |
+-------+-------+--------------------------+
| Drivers |
+------------------------------------------+
| Hardware |
+------------------------------------------+
Programming Tips
Memory Map for 5011
[1] Each address is 16-bit wide. Every two addresses correspond to a 24-bit instruction. Each even address
contains 2 valid bytes; each odd address contains 1 valid byte plus 1 phathom byte.
[2] Each address is 8-bit wide.
Data Location
10 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
_XDATA(N) [1] RAM Data in X-memory, aligned int _XDATA(32) xbuf[] = {1, 2, 3, 4,
at N, with initilization 5};
_YDATA(N) [1] RAM Data in Y-memory, aligned int _YDATA(32) ybuf[16] = {1, 2, 3,
at N, with initilization 4, 5};
__attribute__((space(const))) Flash ROM data, constant, int i __attribute__((space(const))) =
accessed by normal C 10;
statements, but 32K max.
__attribute__((space(prog))) Flash ROM data, read/write by int i __attribute__((space(prog)));
program space visibility
window (psv)
__attribute__((space(auto_psv))) Flash ROM data, read by normal int i __attribute__((space(auto_psv)));
C statements, write
by accessing psv
__attribute__((space(psv))) Flash ROM data, read/write by int i __attribute__((space(psv)));
(psv)
Configuration Bits
These clock sources can be incorporated with interal Phase-locked-loop (PLL) x4, x8 or x16 to yield the
osciallator frequrence FOSC
The system clock is divided by 4 to yield the internal instruction cycle clock, FCY=FOSC/4
FRC with PLLx16 is used to achieve FCY=29.49MHz (29491200Hz or 30MIPS)
11 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
//The code (MACRO) below is to be placed at the top of program (before main)
_FOSC(CSW_FSCM_OFF & FRC_PLL16);
_FWDT(WDT_OFF); //Turn off Watchdog Timer
_FBORPOR(PBOR_ON & BORV_27 & MCLR_DIS & PWRT_16);
_FGS(CODE_PROT_OFF); //Disable Code Protection
Timer
void time_init(void){
TMR1 = 0; // Clear register
PR1 = 4688; // Set period
//============================================================
_T1IF = 0; // Clear interrupt flag
_T1IE = 1; // Enable interrupts
//============================================================
T1CONbits.TCS = 0; // Use internal clock source
T1CONbits.TCKPS = 2; // Prescale Select 1:64
T1CONbits.TON = 1; // Start the timer
}
//********************************************************************
void _ISRFAST _T1Interrupt(void){
_T1IF = 0; // Clear interrupt flag
//Place user code here
}
Time Measurement
To measure the time taken for action(), use the code below:
Interrupt
12 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
User may assign priority level 0-7 to a specific interrupt using IPC. Setting priority to 0 disable a specific
interrupt. Level 7 interrupt has the highest priority.
Current priority level is stored in IPL. Setting IPL to 7 disables all interrupts (except traps). The following
MACROs are defined in <p30f5011.h>:
sti() and cli() are defined to enable and disable global interrupts for time critical functions:
UART
_ _ _ _ _ _
_|S|_|1|_|1|_|1|_|1|_|S|_ (S = Start Bit)
<--------------->
Measured Time
13 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
UxBRG = (Fcy/(16*Baudrate)) -1
= (Fcy/(16*8*Fcy/t_count)) -1
= t_count/128 -1
The following is the code for auto baud rate detection for U2ART:
For 30MIP, tested speeds of transmission include 9600bps, 19200bps, 28800bps, 38400bps and
57600bps.
Initialize UART
14 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
void uart2_init(void){
//=================================================================
// Configure Baud rate
// +-- Default Baud rate = 19.2 kbps
// +-- U2BRG = 30e6 / (16 * 19200) - 1 = 97
unsigned int u2brg = 97;
#if(AUTO_BAUD_DECT>0)
u2brg = uart2_autobaud();
#endif
U2BRG = u2brg;
//=================================================================
// Disable U2ART
U2MODEbits.UARTEN = 0; //Disable U2ART module
//=================================================================
// Configure Interrupt Priority
_U2RXIF = 0; //Clear Rx interrupt flags
_U2TXIF = 0; //Clear Tx interrupt flags
_U2RXIE = 1; //Receive interrupt: 0 disable, 1 enable
_U2TXIE = 1; //Transmit interrupt: 0 disable, 1 enable
//=================================================================
// Configure Mode
// +--Default: 8N1, no loopback, no wake in sleep mode, continue in idle mode
// +--Diable autobaud detect
// +--Enable U2ART module
U2MODEbits.ABAUD = 0; //Disable Autobaud detect from U2RX
U2MODEbits.UARTEN = 1; //U2ART enable
//=================================================================
// Configure Status
// +--Default: TxInt when a char is transmitted, no break char
// +--Default: RxInt when a char is received, no address detect, clear overflow
// +--Enable Transmit
U2STAbits.UTXEN = 1; //Tx enable
}
I2C
Two lines are devoted for the serial communication. SCL for clock, SDA for data.
Standard communication speed includes
dsPIC30f5011 supports standard and fast speed modes. The maximum speed attainable is 1MHz.
Pull-up resistors are required for both SCL and SDA. Minimum pull-up resistance is given by:
Pull-up resistor (min) = (Vdd-0.4)/0.003 ...... [See section 21.8 in Family reference manual]
15 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
StartI2C();
After sending a byte and receiving an acknowledgement from the slave device, ensure to change to idle
state. For example:
MasterWriteI2C(0x55);
IdleI2C();
ADC
Configuration
Interrupt: Clear ADC interrupt flag and enable ADC interrupt. The ADC module will be set to interrupt
when the specified channels are updated.
I/O: Set the corresponding TRISBX bits (digit i/o config) to input (i.e. = 1), and set corresponding bits in
ADPCFG (analog config) to zero.
Scanning Mode: Scan mode is used. In this mode, the Sample and Hold (S/H) is switched between the
channels specified by ADCSSL (Scan select register).
Reference Voltage for S/H: Only MUX A is used. By default, the negative reference voltage of the S/H is
connected to VREF-.
ADCHSbits.CH0NA = 0;
Sampling Rate: T AD refers to the time unit for the ADC clock. To configure the ADC module at 200kbps,
the minimum sampling time of 1T AD = 334ns is required. ADCS<5:0> in ADCON3 register is used to set
the time, which is given by:
16 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
ADCS<5:0> = 2(TAD/TCY)-1
= 2(334e-9/33.34e-9)-1
= 19
Settings for ADC Operation: For 200kbps operation, the voltage references for the ADC voltage are
connected to VREF+ and VREF-. Scan input is enabled, and the module will generate an interrupt when all
selected channels have been scanned.
More Settings for ADC Operation: Turn on the module, select the data output format as unsigned integer,
and allow auto setting of SAMP bit (auto sampling).
16 registers (ADCBUF0 -ADCBUF15) are dedicated to store the ADC data between interrupts. However,
the data in ADCBUFx does not necessarily correspond to the data taken for channel x. Since the lowest
register will always be filled first, when some of the channels are not scanned (i.e. skipped), care must be
taken. The following code checks the ADCSSL register for the current scanning channels and moves the
data to the corresponding position in *adc_buf.
17 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
EEPROM
5011 has 1024 bytes of EEPROM, readable and writable under normal voltage (5V).
To use, declare:
Seek
This function moves the pointer to the desired position before a reading/writing operation is performed.
Read
18 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
.global _readEEByte
_readEEByte:
push TBLPAG ;w0 = base of eeData
mov w0, TBLPAG ;w1 = offset for eeData in byte
tblrdl.b [w1], [w2] ;w2 = pointer to user buffer
pop TBLPAG
return
Write
19 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
.global _eraseEEWord
_eraseEEWord:
push TBLPAG
mov w0, NVMADRU ;w0 = base of eeData
mov w1, NVMADR ;w1 = offset for eeData in word
mov #0x4044, w0
mov w0, NVMCON ;Set to erase operation
push SR ;Disable global interrupts
mov #0x00E0, w0
ior SR
mov #0x55, w0 ;Write the KEY sequence
mov w0, NVMKEY
mov #0xAA, w0
mov w0, NVMKEY
bset NVMCON, #15 ;Start the erase cycle, bit 15 = WR
nop
nop
L1: btsc NVMCON, #15 ;while(NVMCONbits.WR)
bra L1
clr w0
pop SR ;Enable global interrupts
pop TBLPAG
return
.global _writeEEWord
_writeEEWord:
push TBLPAG ;w0 = base of eeData
mov w0, TBLPAG ;w1 = offset for eeData in byte
tblwtl [w2], [w1] ;w2 = pointer to user buffer
mov #0x4004, w0 ;Set to write operation
MOV w0, NVMCON
push SR ;Disable global interrupts
mov #0x00E0, w0
ior SR
mov #0x55, w0 ;Write the KEY sequence
mov w0, NVMKEY
mov #0xAA, w0
mov w0, NVMKEY
bset NVMCON, #15 ;Start the erase cycle, bit 15 = WR
nop
nop
L2: btsc NVMCON, #15 ;while(NVMCONbits.WR)
bra L2
clr w0
pop SR ;Enable global interrupts
pop TBLPAG
return
The PWM module consists of 8 channels using the output compare module of dsPic.
These channels are locate at pin 46 (OC1), 49 (OC2), 50 (OC3), 51 (OC4), 52 (OC5), 53 (OC6), 54
(OC7), 55 (OC8). These pins are shared with port D.
The range of PWM freqeuencies obtainable is 2Hz to 15MHz (See Figure 6.3). Suggested range of
operation is 2Hz to 120kHz. The relationship between resolution r and PWM frequency fPWM is given by:
fPWM = fCY/(Prescale*10rlog(2))
20 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
open()
A timer (either Timer 2 or 3) is needed to determine the pwm period. The following code uses timer 2 for
all 8 channels.
void pwm_open(void){
OC1CON = 0; OC2CON = 0; //Disable all output compare modules
OC3CON = 0; OC4CON = 0;
OC5CON = 0; OC6CON = 0;
OC7CON = 0; OC8CON = 0;
//============================================================
TMR2 = 0; // Clear register
PR2 = 0xFFFF; // Set to Maximum
//============================================================
_T2IP = 7; // Set priority level to 7 (7 Highest)
_T2IF = 0; // Clear interrupt flag
_T2IE = 1; // Enable interrupts
//============================================================
T2CONbits.TCS = 0; // Use internal clock source
T2CONbits.TCKPS = 0; // Prescale Select 1:1
//============================================================
T2CONbits.TON = 1; // Start the timer
}
void _ISR _T2Interrupt(void){
_T2IF = 0; // Clear interrupt flag
}
ioctl()
User should select the channel and set the pwm period using the functions below before issuing the duty
cycle:
21 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
write()
User can change the duty cycle using teh following functions
Propagration Delay
PWM channels sharing the same timer will have their PWM signals synchronised (i.e. the HIGH state of
22 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
DSP Library
1. Vector
2. Window
3. Matrix
4. Filtering
5. Transform
6. Control
Data Types
23 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
To be added.
Build-in Library
Some assembler operators can only be accessed by inline assembly code, for example,
1. Manuipulation of accumulators A and B (add, sub, mul, divide, shift, clear, square)
2. Bit toggling
3. Access to psv (program space visiblity) page and offset
4. Access to table instruction page and offset
Built-in functions are written as C-like function calls to utilize these assembler operators.
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.
24 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
Developer Source
ingenia (http://www.ingenia-cat.com/index.php?lang=en) Assembly (http://www.ingenia-cat.com/download/iBL.s
Tiny Assembly
(http://www.etc.ugal.ro/cchiculita/software/picbootloader.htm) (http://www.etc.ugal.ro/cchiculita/software/tinybld191.zip
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:
.include "p30f5011.inc"
; Uart init
mov #0x8020, W0 ; W0 = 0x8020 -> 1000 0000 0010 0000b
mov W0, U2MODE ; Enable UART, AutoBaud and 8N1
clr U2STA
25 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
.equ CRC, W4
.equ ACK, 0x55
.equ NACK, 0xFF
.equ USER_ADDRESS, 0x0100
.equ START_ADDRESS, 0xAD00 ; Relative to 0x0100
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
6. changing all the related registers of U1ART to U2ART, all U1XXX => U2XXX
7. changing all the related registers of IC1 to IC2, all IC1XXX => IC2XXX
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 (http://www.rxtx.org/) 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:
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.
26 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
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
Communication Protocol
27 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
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
(http://www.prolific.com.tw/eng/downloads.asp?ID=31) and FDTI
(http://www.ftdichip.com/Drivers/VCP.htm) . 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 (http://java.sun.com/products/javacomm/) (javax.comm)
and/or RXTX (http://www.rxtx.org/) to drive the COM port.
2. Modified the bootloader program on PC to support USB communication. e.g. using jUSB
(http://jusb.sourceforge.net/) and JSR-80 (http://javax-usb.org/) (javax.usb). External circuits such as
PIC18F4550 and MAX232 are required.
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
28 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
Hardware
Software
Files
29 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
ICD 2 <-> PC
Plug-in ICD 2 to PC via USB cable
Power-up the target.
Select: Programmer>Select Programmer>MPLAB
If this is the first time the ICD 2 is connected to PC
will automatically download the required OS to IC
it has finished
If you have not connected and powered up the targ
see Warnings on invalid device IDs, and/or running
See results of self test if necessary: Programmer>S
Tab. Refer to ICD2 User's Guide
(http://ww1.microchip.com/downloads/en/DeviceD
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
30 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
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 (http://en.wikipedia.org/wiki/FTP) (FTP): Required files are copied from sever to
client for manipulation
2. Remote Shell (http://en.wikipedia.org/wiki/Remote_Shell) (RSH): Required files are copied from sever to
client for manipulation
3. Network File System (http://en.wikipedia.org/wiki/Network_File_System_%28Sun%29) (NFS): Required
files are manipulated on sever
31 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
Reference:
VxWorks Official Website (http://www.windriver.com/vxworks/)
OS Libraries API Reference (http://www-cdfonline.fnal.gov/daq/commercial/)
Related Libraies
netDrv (netDrv.h): an API using FTP or RSH
nfsDrv (nfsDrv.h): an API using NFS
Hardware
Software
Configuration Bits
dsPIC33 can operate at 40MIPs at maximum. To configure the device using internal FRC, replace the
configuration bits setting as follows:
32 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
UART
No change is required.
I2C
dsPIC33 supports upto 2 I2C devices. As a result, replace all I2C related registers with xxI2Cyy to
xxI2C1yy. For examples:
ADC
There are upto 2 configurations of the ADC module. Replace all ADC-related registers ADxxx to
AD1xxx. For examples:
dsPIC33 have upto 32 ADC channels. The configurations for each channel is therefore splited into 2
registers (High controls channels 16-31; Low controls channels 0-15).
//===========================================================================
// Configure analog i/o
_TRISB0 = 1;
_TRISB1 = 1;
AD1PCFGL = 0xFFFC; //AN0-AN15: Enable AN0 (Vref+) and AN1 (Vref-)
AD1PCFGH = 0xFFFF; //AN16-AN31: Disabled
//===========================================================================
// Configure scan input channels
AD1CSSL = 0x0003; //AN0-AN15: 0 => Skip, 1 => Scan
AD1CSSH = 0x0000; //Skipping AN16-AN31
33 от 34 05.3.2007 г. 14:43
DsPIC30F 5011 Development Board - Open Circuits http://www.opencircuits.com/DsPIC30F_5011_Development_Board
EEPROM
There is no EEPROM in dsPIC33 devices. Please consider to use an external EEPROM using I2C
communication.
Simple PWM
No change is required.
[1] Each address is 16-bit wide. Every two addresses correspond to a 24-bit instruction. Each even address
contains 2 valid bytes; each odd address contains 1 valid byte plus 1 phathom byte.
dsPicBootloader
dsPicProgrammer
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
34 от 34 05.3.2007 г. 14:43