Interfacing seven segment with FreeSoc2 using Cypress Creator

Introduction:

The FreeSoC2 microcontroller based on the PSoC 5LP (Programmable System on a Chip) brings together features of the programmable devices and microcontroller-type systems on chips into one package. By placing a programmable fabric between the peripherals and the pins, the FreeSoC2 allows any function to be routed to any pin! Moreover, the on-board PSoC includes a number of programmable blocks which allow the user to define arbitrary digital and analog circuits for their specific application. To get the most out of the device, you will need to use the PSoC Creator IDE.

Step 1: Open PSOC creator IDE.

1

Step 2: File-> new project -> design -> PSoC 5LP design & save with desired name.

2

 

Step 3: Open TopDesign.cysch from workspace explorer.

3

Step 4: To Interface the firmware with digital I/O‘s we need control register. Select Control Register from Component catalog on right side of the window.

4

Step 5: Drag the Control register to workspace.

5

Step 6: Double click on the Control register and enter name and No. of outputs

6.

 

Step 7: By using Wire component, connect all the controls (0-6) .

7

Step 8: Select digital output pin from the components catalogue and drag into workspace.

8

Step 9: Double click the output pin and change the name and Select the No. of pins as 7.

9

Step 10: Tick the Display as bus option in the Mapping tab.

10

Step 11: connect the output pin with control reg through the wire component.

11

Step 12: Double click that wire and change the name and select BUS in indices and select LEFT index 0 and Right index 6 or vice versa if 7 seg-display print in inappropriate way.

12

Step 13: Double click individual wires and give the name as 0,1,2,3,4,5,6 and select Bit in indices.

13

It will look like this,

13a

Step 14: Select 7segmenttest.cydwr from the workspace explorer.

14

Step 15: Select the desired Port where we are able decide the pin no’s.

15

Step 16: Open the main.c from workspace explorer

16

Code:

#include <project.h>

uint8 i;

void count(uint8 j)

{

switch(j)

{

case 0:

{

seven_segment_Write(0x40); // 7-segment code for 0

break;

}

case 1:

{

seven_segment_Write(0x79);// 7-segment code for 1

break;

}

case 2:

{

seven_segment_Write(0x24); //7-segment code for 2

break;

}

case 3:

{

seven_segment_Write(0x30); //7-segment code for 3

break;

}

case 4:

{

seven_segment_Write(0x19); //7-segment code for 4

break;

}

case 5:

{

seven_segment_Write(0x12); //7-segment code for 5

break;

}

case 6:

{

seven_segment_Write(0x02); //7-segment code for 6

break;

}

case 7:

{

seven_segment_Write(0x78); //7-segment code for 7

break;

}

case 8:

{

seven_segment_Write(0x00); //7-segment code for 8

break;

}

}

}

 

int main()

{

CyGlobalIntEnable; /* Enable global interrupts. */

 

/* Place your initialization/startup code here (e.g. MyInst_Start()) */

 

for(;;) //infinite loop

{

for(i=0;i<=9;i++)  //Counter for 0 to 8

{

count(i);

CyDelay(1000);

}

}

}

 

/* [] END OF FILE */

 

Note:

7-segment display:

7_segment_display.svg

For common cathode:

7segchart

For common anode change all zeroes to 1 and vice versa.

Example:

Suppose if we want to print 5 in seven segment then binary No. is (00100010 – LSB first ) then its hexa decimal value is 0x12,likewise all digits have to calculated and assign in code.

Here Decimal point is left open.Considered as 0.

Connect Micro B cable to the debugger port

Step 17: Click Build -> Generate Application

19

Step 17: Click Debug -> Program

20

Step 18: Connect the 7 segment display with appropriate pins selected in step 15

21

 

For product link:

  1. http://www.tenettech.com/product/7241/freesoc2-development-board-psoc5lp
  2. http://tenettech.com/product/6655/universal-gpio-board

 For application note: http://www.tenettech.com/product/7313/interfacing-seven-segment-display-with-freesoc2-application-note         

 For more information please visit: www.tenettech.com

For technical query please send an e-mail: info@tenettech.com

Leave a Reply

Your email address will not be published. Required fields are marked *