

Got the display U18 running thru all display values O-F,U,r,- . Using Olimex Atmel mega16 board. Added Molex 14 pin connect in place of ribbon cable. The Olimex has a Jtag interface. I am using the Olimex Atmel USB to Jtag emulator. It interfaces to Atmel's AVR Studio 4 nicely.
I am using the CodeVision AVR C complier. Both programs make a very nice development enviroment.
void display_u18(int n)
{ u18_buffer = U17SegmentTable[n];if ( (u18_buffer & 0x80) ==0x80)
{ /* state 0*/
PORTA=0x00;
U18 =1;
delay_us(50);
}
else
{
U18=0;
delay_us(50);
}
if ( (u18_buffer & 0x40) ==0x40)
{ /* state 1*/
PORTA=0x01;
U18 =1;
delay_us(50);
}
else
{
U18=0;
delay_us(50);
}
... State 7.
This is the table to light the segments for U17 U18
const unsigned char U17SegmentTable[20]=
{ 0xFC, /*0 */ 0x60, /*1 */ 0xD9, /*2 */ 0xF1, /*3 */ 0x65, /*4 */ 0xB5, /*5 */ 0xBD, /*6 */ 0xE0, /*7 */ 0xFD, /*8 */ 0xF5, /*9 */ 0xED, /*A */ 0x3D, /*B */ 0x9C, /*C */ 0x79, /*D */ 0x9D, /*E */ 0x8D, /*F */ 0x7D, /*U */ 0x09, /*r */ 0x01, /*- */ 0x02 /*dp*/ };
U4 & U10 are different because the display is inverted.. Nice touch to save a few via holes.
const unsigned char U4SegmentTable[20]= { 0xFC, /*0 */ 0x0C, /*1 */ 0xD9, /*2 */ 0x9D, /*3 */ 0x2D, /*4 */ 0xB5, /*5 */ 0xF5, /*6 */ 0x1C, /*7 */ 0xFD, /*8 */ 0xBD, /*9 */ 0x7D, /*A */ 0xE5, /*B */ oxFo/*C */ 0xCD, /*D */ 0xF3, /*E */ 0x71, /*F */ 0xEC, /*U */ 0x41, /*r */ 0x01, /*- */ 0x02 /*dp*/ };
Interrupt Timer 0 routine:
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
display_u18(u18_value);
a_counter(); lights the led display on,off,flash
check_keypad(); check the key depression.
TCNT0=255; /*set for 1us timeout Olimex 6mhz*/
}
In the main program
for (i=0;i<19;i++)
{ u18_value =i;
}
Next task is to get all 4 digits operating.
No comments:
Post a Comment