CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

ICM7218AIJI CCS C Driver Required

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Nisar



Joined: 16 Nov 2007
Posts: 20

View user's profile Send private message

ICM7218AIJI CCS C Driver Required
PostPosted: Sat Aug 22, 2009 5:36 am     Reply with quote

Hi all
I want to drive 8 common anode seven segment display with ICM7218AIJI. I have to under stand problem ICM7218 Data sheet. Plz any one hint me how I write its CCS C program to run displays.
Regards
Nisar
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Aug 23, 2009 1:24 pm     Reply with quote

Quote:

Plz any one hint me how I write its CCS C program to run displays.

The icm7218 has a parallel interface consisting of an 8 bit data bus and
two control signals. For the 8 data bits, you can use Port B. Then set
the data bits to a specified value with the output_b() function.

There are two control signals, Write and Mode. The Write signal idles
(i.e., the in-active state) at a high level, and the Mode signal idles at a
low level. You can use two i/o pins on the PIC for these signals, such as
pins C0 and C1. Then use output_low() and output_high() to control
these signals.

This page has a schematic of the connections (to a PC parallel port):
http://insentricity.com/?postid=57

This is the Linux used on the page above:
http://f2z.net/LED-Display/icm7218.c

This is the ICM7218 data sheet:
http://www.intersil.com/data/fn/FN3159.pdf

You can translate the Linux code to CCS. Look at the timing diagrams
on page 6 of the ICM7218 data sheet (Figures 4 and 5).

I'll go through his display_string() routine and make comments on what
you need to do to convert it to CCS. I'll put comments above each
section of code.
Quote:

void display_string(const char *str, int fd)
{
unsigned char status, control, data;
unsigned char mask;

The structure declaration below is not needed. It can all be done with the
output_b(), output_high() and output_low() functions.

struct ppdev_frob_struct frob;

char buf[DISPLAY_DIGITS + 1];
int i;

for (i = 0; i < DISPLAY_DIGITS; i++)
buf[i] = ' ';
strncpy(buf, str, DISPLAY_DIGITS);


Here, he is setting the Mode and Write signals to their idle states.
You can use output_low() for Mode and output_high() for Write, to do
this, instead of these 3 lines below.

/* Turn off write and mode, pins are inverted */
frob.mask = PARPORT_CONTROL_STROBE | PARPORT_CONTROL_SELECT;
frob.val = PARPORT_CONTROL_SELECT;
ioctl(fd, PPFCONTROL, &frob);


Here, he's setting the 8-bit data bus to a value consisting of two constants
that are bitwise OR'ed together. You can use output_b() to write 'data'
to the data bus of the ICM7218 instead of the ioctl() function.

data = ICM_NOTSHUTDOWN | ICM_HEXA;
ioctl(fd, PPWDATA, &data);


Here, he's apparently trying to initialize the chip by sending 9 sequential
write pulses to it. The write pulses are negative-going pulses. You
can use output_low() and output_high() inside the for() loop to do this.
This will replace all the other code inside the for() loop.

/* Try to get the chip into a known state */
for (i = 0; i < 9; i++) {
frob.mask = PARPORT_CONTROL_STROBE;
frob.val = PARPORT_CONTROL_STROBE;
ioctl(fd, PPFCONTROL, &frob);
frob.val = 0;
ioctl(fd, PPFCONTROL, &frob);
}

--------------------------------------------
This section between the dotted lines, is the same as the first part of
the timing diagram shown in Figure 5 of the ICM7218 data sheet.
It consists of
1. Write data to the data bus.
2. Set the Mode signal high.
3. Pulse the Write signal once (make a negative pulse).
4. Set the Mode signal low.


Here he's writing 'data' to the bus again. You can do it with output_b().
Again, this replaces the ioctl() function.

data = ICM_NOTSHUTDOWN | ICM_NOTDECODE | ICM_DATA;
ioctl(fd, PPWDATA, &data);

Set the Mode signal high. You can use output_high() to do this
instead of these lines below.

/* Start control mode */
frob.mask = PARPORT_CONTROL_SELECT;
frob.val = 0;
ioctl(fd, PPFCONTROL, &frob);

Set the Write signal low. You can use output_low() to do this
instead of these lines below.

/* Pulse write */
frob.mask = PARPORT_CONTROL_STROBE;
frob.val = PARPORT_CONTROL_STROBE;
ioctl(fd, PPFCONTROL, &frob);

Set the Write signal high. You can use output_high() for this
instead of these lines below.

/* End the pulse */
frob.val = 0;
ioctl(fd, PPFCONTROL, &frob);

Set the Mode signal low. You can use output_low() to do this
instead of these lines below.

/* End control mode */
frob.mask = PARPORT_CONTROL_SELECT;
frob.val = PARPORT_CONTROL_SELECT;
ioctl(fd, PPFCONTROL, &frob);

--------------------------------------------

This is the next part of Figure 5 in the ICM7218 data sheet, where it
shows 8 sequential Write pulses. He does this with a for() loop that
counts through 8 iterations.

for (i = 0; i < 8; i++) {
/* Data goes in reverse */
data = buf[7 - i];
data = 0x80 ^ ((data & 0x80) | (segments[data & 0x7f]));

Here, he is writing 'data' to the data bus. You can do this with output_b()
ioctl(fd, PPWDATA, &data);


In these next two sections, he is creating the negative-going write pulse.
You can do this with output_low() and output_high() to do this, instead
of these lines below.

/* Pulse write */
frob.mask = PARPORT_CONTROL_STROBE;
frob.val = PARPORT_CONTROL_STROBE;
ioctl(fd, PPFCONTROL, &frob);

/* End the pulse */
frob.val = 0;
ioctl(fd, PPFCONTROL, &frob);
}

This return statement is not needed because the function automatically
returns when it's done.

return;
}
Nisar



Joined: 16 Nov 2007
Posts: 20

View user's profile Send private message

ICM7218AIJI CCS C Driver Required
PostPosted: Mon Aug 24, 2009 1:58 am     Reply with quote

Thanks
Nisar



Joined: 16 Nov 2007
Posts: 20

View user's profile Send private message

PostPosted: Mon Sep 28, 2009 5:00 am     Reply with quote

Hello every one
I want to display 10 character numeric string from key board via serial port on common-anode 10 seven segments using ICM7218A driver. When I put 10 character numeric string, my code is ok, but my problem is that I want capture only 0 to 9 numeric keys. But when I Press "A" it sends 10 and when "B" sends 20 and so on, on seven segments. How can I capture 0 to 9 numeric characters only?
My code is:
Code:

/*Sending 10 character Serially Numeric Data on Common Anode Seven Segment Display
Using ICM7218A*/
#if defined(__PCM__)
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOPUT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_c6, rcv=PIN_c7, bits=8)
#endif

#include <stdlib.h>
#include <string.h>
//#include <input.c>
#define mode_h output_high(pin_e0);
#define mode_l output_low(pin_e0);

#define write_h_sound output_high(pin_e1);
#define write_l_sound output_low(pin_e1);

#define write_h_immersion output_high(pin_e2);
#define write_l_immersion output_low(pin_e2);

INT iresult;
char string1[10];
char string[10];
char sound[5];
char immersion[5];


#use rs232(baud=9600, xmit=PIN_c6, rcv=PIN_c7, bits=8)
#int_rda
void serial_isr() {
#use rs232(baud=9600, xmit=PIN_c6, rcv=PIN_c7, bits=8)
gets(string);
iresult=strlen(string);
strcpy(string1,string);

string[0x00]=' ';
string[0x01]=' ';
string[0x02]=' ';
string[0x03]=' ';
string[0x04]=' ';
string[0x05]=' ';
string[0x06]=' ';
string[0x07]=' ';
string[0x08]=' ';
string[0x09]=' ';
//string[0x0a]=' ';
//string[0x0b]=' ';
}

byte digit_num,data;

display_time();
disply_time();

display_sound();
disply_sound();

display_immersion();
disply_immersion();


main()
{
enable_interrupts(global);
enable_interrupts(int_rda);

delay_ms(5000);
   
string1[0x00]=0x00;
string1[0x01]=0x00;
string1[0x02]=0x00;
string1[0x03]=0x00;
string1[0x04]=0x00;
string1[0x05]=0x00;
string1[0x06]=0x00;
string1[0x07]=0x00;
string1[0x08]=0x00;
string1[0x09]=0x00;
//string1[0x0a]=0x00;
//string1[0x0b]=0x00;

while(1)
{

//if(string1[0x00]=='S')
//{

sound[0x00]=string1[0x00];
sound[0x01]=string1[0x01];
sound[0x02]=string1[0x02];
sound[0x03]=string1[0x03];
sound[0x04]=string1[0x04];
//}

//else if(string1[0x06]=='I')

//{
immersion[0x00]=string1[0x05];
immersion[0x01]=string1[0x06];
immersion[0x02]=string1[0x07];
immersion[0x03]=string1[0x08];
immersion[0x04]=string1[0x09];

//}

display_sound();
display_immersion();

#use rs232(baud=9600, xmit=PIN_c6, rcv=PIN_c7, bits=8)

}
}

disply_sound()
{
write_h_sound
mode_h
output_d(digit_num);
write_l_sound
write_h_sound
mode_l

OUTPUT_D(data);

write_l_sound
write_h_sound

}

disply_immersion()
{
write_h_immersion
mode_h
output_d(digit_num);
write_l_immersion
write_h_immersion
mode_l

OUTPUT_D(data);

write_l_immersion
write_h_immersion

}
////////////////////////////////Sound Velocity DISPLAY/////////////////////////
display_sound(){
output_low(pin_e1);

digit_num=0x58;
data=sound[0x04];
disply_sound();

digit_num=0x59;
data=sound[0x03];
disply_sound();

digit_num=0x5a;
data=sound[0x02];
disply_sound();

digit_num=0x5b;
data=sound[0x01];
disply_sound();

digit_num=0x5c;
data=sound[0x00];
disply_sound();
}
////////////////////////////////IMMERSION DISPLAY//////////////////////////////

display_immersion(){

output_low(pin_e0);
digit_num=0x58;
data=immersion[0x04];
disply_immersion();

digit_num=0x59;
data=immersion[0x03];
disply_immersion();

digit_num=0x5a;
data=immersion[0x02];
disply_immersion();

digit_num=0x5b;
data=immersion[0x01];
disply_immersion();

digit_num=0x5c;
data=immersion[0x00];
disply_immersion();
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group