You have no items in your shopping cart.

Subtotal: 0.00

DsPIC30F4011 Development Board

The DsPIC30F4011 Development Board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through USB port.

Microchip’s dsPIC30F (dsPIC30F4011), Development Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 16-bit Microcontrollers.

I2C (Inter Integrated Circuit)

The I2C (Inter-IC) bus is a bi-directional two-wire serial bus that provides a communication link between integrated circuits (ICs).I2C is a synchronous protocol that allows a master device to initiate communication with a slave device. Data is exchanged between these devices.

EEPROM

EEPROM (electrically erasable programmable read-only memory) is user-modifiable read-only memory (ROM) that can be erased and reprogrammed (written to) repeatedly through the application of higher than normal electrical voltage. It is a type of non-volatile memory used in computers and other electronic devices to store small amounts of data that must be saved when power is removed, e.g., calibration tables or device configuration.

Interfacing I2C - EEPROM

Fig. 1 shows how to interface the EEPROM with microcontroller through I2C. I2C is a Master-Slave protocol. I2C has a clock pulse along with the data. Normally, the master device controls the clock line, SCL. This line dictates the timing of all transfers on the I2C bus. No data will be transferred unless the clock is manipulated. All slaves are controlled by the same clock, SCL.

I2c bus supports many devices, each device is recognized by a unique address—whether it’s a micro-controller, LCD Driver, memory or keyboard interface and can operate as transmitter or receiver based on the functioning of the device. The controller designed controls the EEPROM device through I2C protocol. The I2C Controller here acts as a master device and controls EEPROM which acts as a slave. The read-write operations are accomplished by sending a set of control signals including the address and/or data bits. The control signals must be accompanied with proper clock signals.

Fig. 1 Interfacing I2C - EEPROM to Microcontroller

Interfacing I2C – EEPROM with dsPIC30F4011

We now want to Read, write and Erase EEPROM by using I2C in DsPIC30F4011 Development Board. Wiring up an I2C based EEPROM to the I2C port is relatively simple. The basic operation of the I2C based EEPROM's is to send a command, such as WRITE, followed by an address and the data. In WRITE operation, the EEPROM to store the data.

In DSPIC30F4011 Development Kit, 2 nos. of EEPROM lines are controlled by I2C Enabled drivers. I2C Lines serial clock SCL (PORTF.3), serial data SDA (PORTF.2) connected to the I2C based serial EEPROM IC. The EEPROM read & write operations are done in dsPIC30F4011 Development Kit by using these SDA & SCL I2C lines.

Pin Assignment with dsPIC30F4011

Circuit Diagram to Interface I2C–EEPROM

Source Code

The Interfacing I2C – EEPROM with dsPIC30F4011 program is very simple and straight forward that read, write and erase operations in EEPROM by using I2C & the value is displayed in serial port. A delay is occurring in every single data read or write in EEPROM. The delay depends on compiler how it optimizes the loops as soon as you make changes in the options the delay changes.

C Program to I2C – EEPROM Display

***************************************************************************************

Title : Program to read, write & erase of I2C - EEPROM

***************************************************************************************

#include

#include "p30f4011.h"

#include "delay.c"

_FOSC(CSW_FSCM_OFF & XT);

_FWDT(WDT_OFF);

_FBORPOR(PBOR_ON & MCLR_EN);

_FGS(CODE_PROT_OFF);

#define XTFREQ 10000000

#define I2C_FREQ 400000

#define FOSC XTFREQ/4

#define BAUDRATE 9600

#define BRGVAL ((FOSC/BAUDRATE)/16)-1

#define I2C_Baud ((XTFREQ/I2C_FREQ)-(XTFREQ/1111111))-1

#define I2C_WRITE 0xa0

#define I2C_READ 0xa1 unsigned char data[17]={"I2C Test Program"};

int i; void wait_trasmit();

void wait_receive();

void I2CWrite(void);

void I2CRead(void);

void i2c_init(void);

void Serial_init(void);

int main()

{

Delay_ms10M(100);

i2c_init();

Serial_init();

Delay_ms10M(20);

putch('x');

I2CWrite();

Delay_ms10M(50);

while(1)

{

I2CRead();

Delay_ms10M(500);

}

return 0;

}

void i2c_init()

{

I2CCON = 0x8000;

I2CBRG = I2C_Baud;

I2CSTAT= 0x0000;

}

void I2CWrite()

{

I2CCONbits.SEN=1;

wait_trasmit();

I2CTRN = I2C_WRITE;

wait_trasmit();

I2CTRN = 0x00;

wait_trasmit();

for(i=0;i<16;i++)

{

I2CTRN=data[i];

wait_trasmit();

}

I2CCONbits.PEN=1;

wait_trasmit();

}

void I2CRead()

{

int y;

I2CCONbits.SEN=1;

wait_trasmit();

I2CTRN = I2C_WRITE;

wait_trasmit();

I2CTRN = 0x00;

wait_trasmit();

for(y=0;y<16;y++)

{

I2CCONbits.RSEN=1;

wait_trasmit();

I2CTRN = I2C_READ;

wait_trasmit();

I2CCONbits.RCEN=1;

wait_trasmit();

I2CCONbits.ACKDT=1;

I2CCONbits.ACKEN=1;

I2CCONbits.PEN=1;

wait_trasmit();

U2TXREG = I2CRCV;

Delay_ms10M(30);

}

U2TXIF=1;

}

void putch(unsigned char SendDat)

{

while(IFS1bits.U2TXIF==0);

IFS1bits.U2TXIF=0;

U2TXREG = SendDat;

}

To compile the above C code you need the Mplab software & Microchip C30 Compiler. They must be properly set up and a project with correct settings must be created in order to compile the code. To compile the above code, the C file must be added to the project.

In Mplab, you want to develop or debug the project without any hardware setup. You must compile the code for generating HEX file. In debugging Mode, you want to check the port output without DsPIC30F4011 Development Board.

The PICKIT2 software is used to download the hex file into your microcontroller IC DSPIC30F4011 through USB.

Testing the I2C – EEPROM with dsPIC30F4011

Give +9V power supply to DsPIC30F4011 Development Board; the EEPROM device is connected with the DsPIC30F4011 Development Board. First check the entire EEPROM device fixed properly. A serial cable is connected between the microcontroller and PC.

In PC, open the Hyper Terminal for displaying the values from EEPROM through I2C.

  • If you want to write any data into EEPROM then you just pressed the switch, sw20. Now, you can write any values into the EEPROM permanently.
  • If you want to read data from EEPROM then you just pressed the switch, sw21. Now you can read any data from EEPROM. If any data is written by you in EEPROM particular address then you just read that data from that particular address by using that switch.
  • If you want to erase any data from EEPROM then you just pressed the switch, sw22. Now you can erase any data from EEPROM as you wish.
  • All the above operations are performed in EEPROM with EEPROM address. When the EEPROM address is correct, then only you can write, read, and erase data’s correctly in EEPROM.

If any data is not coming in Hyper Terminal, then you just check the serial cable is working or not. Otherwise you just check the code with debugging mode in Mplab. If you want to see more details about debugging just see the videos in below link.

  • How to create & Debug a Project in Mplab using dsPIC30F.

General Information

  • For proper working use the components of exact values as shown in Circuit file. Use new components.
  • Solder everything in a clean way. A major problem arises due to improper soldering, solder jumps and loose joints. Use the exact value crystal shown in schematic.
  • More instructions are available in following articles,
      

dSPIC Development board

User Manual of DSPIC Development Board

Creating & Debugging a Project in MPLAB using dsPIC30F