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

Char Generator in ROM

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Jerry.I
Guest







Char Generator in ROM
PostPosted: Fri Apr 11, 2003 5:14 pm     Reply with quote

I am currently have a 2K character generator in ROM using a 16F876 eg. below at end. I am only showing part of it. The code below lets me access the character fields (dots leds) to turn on leds of a display.

If the character to display is 'A' Ascii 0x41, 65 decimal

0x41 * 3 = 0xc3 = 195 dec. // 65th row of char gen.
add led row eg 3. // data for row 3

chr_data_ptr = 198

data returned would be 0x1f

row 0 -> ... = 0x0e
row 1 -> . . = 0x11
row 2 -> . . = 0x11
row 3 -> ..... = 0x1f -> eg. data for above
row 4 -> . . = 0x11
row 5 -> . . = 0x11
row 6 -> . . = 0x11
row 7 -> = 0x00

0x0E,0x11,0x11,0x1F,0x11,0x11,0x11,0x00, //;65 A
^ ^ ^ ^ ^
195 196 197 198 199 ...

char ChrGenData(char* char_data, char* led_row)
{
chrgen_data_ptr = char_data;

chrgen_data_ptr = (chrgen_data_ptr << 3); Mult x 8
chrgen_data_ptr = chrgen_data_ptr + led_row; // Add led row
chrgen_data_ptr = chrgen_data_ptr + CHRGEN_ADDR; // + 0x1700
return(read_program_eeprom(chrgen_data_ptr)); //get led data
}

After all this I now want to implement this for the pic18F252.

This would still work but since 18F is 16 bit the way that I have written the #rom statements will be very in-efficient on space used.


#ROM 0x1700 = {0x0E,0x11,0x11,0x1F,0x11,0x11,0x11,0x00}

data in ROM would be starting at 0x1700

00 0e, 00 11, 00 11, 00 1f, 00 11, 00 11, 00 11, 00 00 ->hex

Hi byte of 16bit value always 00. in-efficient

I found from a previous post this would work for me.

#rom int8 0x1700 = { 0x0e }
#rom int8 0x1701 = { 0x11 }
#rom int8 0x1702 = { 0x11 }
#rom int8 0x1703 = { 0x1f }
#rom int8 0x1704 = { 0x11 }
#rom int8 0x1705 = { 0x11 }
#rom int8 0x1706 = { 0x11 }
#rom int8 0x1707 = { 0x0e }

Is there an easier way of doing this without retyping 2Ks worth
of the character generator.

Thanks in advance for any info given

sorry for the long message post.

Jerry



//
///////////////////////////////////////////////////////////////
// CHARACTER GENERATOR
// 5X7 CHARACTERS IN A 6X8 CHARACTER FIELD
//////////////////////////////////////////////////////////////
//

#ROM 0x1700 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;0
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;1
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;2
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;3
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;4
.
.
.
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;30
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;31
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;32
0x04,0x04,0x04,0x04,0x04,0x00,0x04,0x00, //;33
0x0A,0x0A,0x0A,0x00,0x00,0x00,0x00,0x00, //;34
0x0A,0x0A,0x1F,0x0A,0x1F,0x0A,0x0A,0x00, //;35
0x04,0x0F,0x14,0x0E,0x05,0x1E,0x04,0x00, //;36
0x18,0x19,0x02,0x04,0x08,0x13,0x03,0x00, //;37
0x08,0x14,0x14,0x08,0x15,0x12,0x0D,0x00, //;38
0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00, //;39
0x02,0x04,0x08,0x08,0x08,0x04,0x02,0x00, //;40
0x08,0x04,0x02,0x02,0x02,0x04,0x08,0x00, //;41
0x04,0x15,0x0E,0x1F,0x0E,0x15,0x04,0x00, //;42
0x00,0x04,0x04,0x1F,0x04,0x04,0x00,0x00, //;43
0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00, //;44
0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00, //;45
0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00, //;46
0x00,0x01,0x02,0x04,0x08,0x10,0x00,0x00, //;47
0x0E,0x11,0x13,0x15,0x19,0x11,0x0E,0x00, //;48 0
0x04,0x0C,0x04,0x04,0x04,0x04,0x0E,0x00, //;49 1
0x0E,0x11,0x01,0x06,0x08,0x10,0x1F,0x00, //;50 2
0x0E,0x11,0x01,0x06,0x01,0x11,0x0E,0x00, //;51 3
.
.
.
0x0E,0x11,0x01,0x0D,0x15,0x15,0x0E,0x00, //;64 @
0x0E,0x11,0x11,0x1F,0x11,0x11,0x11,0x00, //;65 A
0x1E,0x11,0x11,0x1E,0x11,0x11,0x1E,0x00, //;66 B
0x0E,0x11,0x10,0x10,0x10,0x11,0x0E,0x00, //;67 C
0x1E,0x11,0x11,0x11,0x11,0x11,0x1E,0x00, //;68 D
0x1F,0x10,0x10,0x1E,0x10,0x10,0x1F,0x00, //;69 E
0x1F,0x10,0x10,0x1E,0x10,0x10,0x10,0x00, //;70 F
0x0F,0x10,0x10,0x13,0x11,0x11,0x0F,0x00, //;71 G
0x11,0x11,0x11,0x1F,0x11,0x11,0x11,0x00, //;72 H
0x0E,0x04,0x04,0x04,0x04,0x04,0x0E,0x00, //;73 I
0x01,0x01,0x01,0x01,0x11,0x11,0x0E,0x00, //;74 J
0x11,0x12,0x14,0x18,0x14,0x12,0x11,0x00, //;75 K
0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0x00, //;76 L
0x11,0x1B,0x15,0x15,0x11,0x11,0x11,0x00, //;77 M
0x11,0x19,0x15,0x13,0x11,0x11,0x11,0x00, //;78 N
0x0E,0x11,0x11,0x11,0x11,0x11,0x0E,0x00, //;79 O
0x1E,0x11,0x11,0x1E,0x10,0x10,0x10,0x00, //;80 P
0x0E,0x11,0x11,0x11,0x15,0x12,0x0D,0x00, //;81 Q
0x1E,0x11,0x11,0x1E,0x14,0x12,0x11,0x00, //;82 R
0x0F,0x10,0x10,0x0E,0x01,0x01,0x1E,0x00, //;83 S
0x1F,0x04,0x04,0x04,0x04,0x04,0x04,0x00, //;84 T
0x11,0x11,0x11,0x11,0x11,0x11,0x0E,0x00, //;85 U
0x11,0x11,0x11,0x11,0x11,0x0A,0x04,0x00, //;86 V
0x11,0x11,0x11,0x15,0x15,0x1B,0x11,0x00, //;87 W
0x11,0x11,0x0A,0x04,0x0A,0x11,0x11,0x00, //;88 X
0x11,0x11,0x0A,0x04,0x04,0x04,0x0E,0x00, //;89 Y
0x1F,0x01,0x02,0x04,0x08,0x10,0x1F,0x00, //;90 Z
.
.
.

___________________________
This message was ported from CCS's old forum
Original Post ID: 13621
Jerry.I
Guest







Re: Char Generator in ROM
PostPosted: Fri Apr 11, 2003 5:16 pm     Reply with quote

Message got a little scrambled after posted.



:=I am currently have a 2K character generator in ROM using a 16F876 eg. below at end. I am only showing part of it. The code below lets me access the character fields (dots leds) to turn on leds of a display.
:=
:=If the character to display is 'A' Ascii 0x41, 65 decimal
:=
:=0x41 * 3 = 0xc3 = 195 dec. // 65th row of char gen.
:=add led row eg 3. // data for row 3
:=
:=chr_data_ptr = 198
:=
:=data returned would be 0x1f
:=
:=row 0 -> ... = 0x0e
:=row 1 -> . . = 0x11
:=row 2 -> . . = 0x11
:=row 3 -> ..... = 0x1f -> eg. data for above
:=row 4 -> . . = 0x11
:=row 5 -> . . = 0x11
:=row 6 -> . . = 0x11
:=row 7 -> = 0x00
:=
:= 0x0E,0x11,0x11,0x1F,0x11,0x11,0x11,0x00, //;65 A
:= ^ ^ ^ ^ ^
:= 195 196 197 198 199 ...
:=
:=char ChrGenData(char* char_data, char* led_row)
:={
:= chrgen_data_ptr = char_data;
:=
:= chrgen_data_ptr = (chrgen_data_ptr << 3); Mult x 8
:= chrgen_data_ptr = chrgen_data_ptr + led_row; // Add led row
:= chrgen_data_ptr = chrgen_data_ptr + CHRGEN_ADDR; // + 0x1700
:= return(read_program_eeprom(chrgen_data_ptr)); //get led data
:=}
:=
:=After all this I now want to implement this for the pic18F252.
:=
:=This would still work but since 18F is 16 bit the way that I have written the #rom statements will be very in-efficient on space used.
:=
:=
:=#ROM 0x1700 = {0x0E,0x11,0x11,0x1F,0x11,0x11,0x11,0x00}
:=
:=data in ROM would be starting at 0x1700
:=
:=00 0e, 00 11, 00 11, 00 1f, 00 11, 00 11, 00 11, 00 00 ->hex
:=
:=Hi byte of 16bit value always 00. in-efficient
:=
:=I found from a previous post this would work for me.
:=
:=#rom int8 0x1700 = { 0x0e }
:=#rom int8 0x1701 = { 0x11 }
:=#rom int8 0x1702 = { 0x11 }
:=#rom int8 0x1703 = { 0x1f }
:=#rom int8 0x1704 = { 0x11 }
:=#rom int8 0x1705 = { 0x11 }
:=#rom int8 0x1706 = { 0x11 }
:=#rom int8 0x1707 = { 0x0e }
:=
:=Is there an easier way of doing this without retyping 2Ks worth
:=of the character generator.
:=
:=Thanks in advance for any info given
:=
:=sorry for the long message post.
:=
:=Jerry
:=
:=
:=
:=//
:=///////////////////////////////////////////////////////////////
:=// CHARACTER GENERATOR
:=// 5X7 CHARACTERS IN A 6X8 CHARACTER FIELD
:=//////////////////////////////////////////////////////////////
:=//
:=
:=#ROM 0x1700 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;0
:= 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;1
:= 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;2
:= 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;3
:= 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;4
:= .
:= .
:= .
:= 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;30
:= 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;31
:= 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;32
:= 0x04,0x04,0x04,0x04,0x04,0x00,0x04,0x00, //;33
:= 0x0A,0x0A,0x0A,0x00,0x00,0x00,0x00,0x00, //;34
:= 0x0A,0x0A,0x1F,0x0A,0x1F,0x0A,0x0A,0x00, //;35
:= 0x04,0x0F,0x14,0x0E,0x05,0x1E,0x04,0x00, //;36
:= 0x18,0x19,0x02,0x04,0x08,0x13,0x03,0x00, //;37
:= 0x08,0x14,0x14,0x08,0x15,0x12,0x0D,0x00, //;38
:= 0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00, //;39
:= 0x02,0x04,0x08,0x08,0x08,0x04,0x02,0x00, //;40
:= 0x08,0x04,0x02,0x02,0x02,0x04,0x08,0x00, //;41
:= 0x04,0x15,0x0E,0x1F,0x0E,0x15,0x04,0x00, //;42
:= 0x00,0x04,0x04,0x1F,0x04,0x04,0x00,0x00, //;43
:= 0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00, //;44
:= 0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00, //;45
:= 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00, //;46
:= 0x00,0x01,0x02,0x04,0x08,0x10,0x00,0x00, //;47
:= 0x0E,0x11,0x13,0x15,0x19,0x11,0x0E,0x00, //;48 0
:= 0x04,0x0C,0x04,0x04,0x04,0x04,0x0E,0x00, //;49 1
:= 0x0E,0x11,0x01,0x06,0x08,0x10,0x1F,0x00, //;50 2
:= 0x0E,0x11,0x01,0x06,0x01,0x11,0x0E,0x00, //;51 3
:= .
:= .
:= .
:= 0x0E,0x11,0x01,0x0D,0x15,0x15,0x0E,0x00, //;64 @
:= 0x0E,0x11,0x11,0x1F,0x11,0x11,0x11,0x00, //;65 A
:= 0x1E,0x11,0x11,0x1E,0x11,0x11,0x1E,0x00, //;66 B
:= 0x0E,0x11,0x10,0x10,0x10,0x11,0x0E,0x00, //;67 C
:= 0x1E,0x11,0x11,0x11,0x11,0x11,0x1E,0x00, //;68 D
:= 0x1F,0x10,0x10,0x1E,0x10,0x10,0x1F,0x00, //;69 E
:= 0x1F,0x10,0x10,0x1E,0x10,0x10,0x10,0x00, //;70 F
:= 0x0F,0x10,0x10,0x13,0x11,0x11,0x0F,0x00, //;71 G
:= 0x11,0x11,0x11,0x1F,0x11,0x11,0x11,0x00, //;72 H
:= 0x0E,0x04,0x04,0x04,0x04,0x04,0x0E,0x00, //;73 I
:= 0x01,0x01,0x01,0x01,0x11,0x11,0x0E,0x00, //;74 J
:= 0x11,0x12,0x14,0x18,0x14,0x12,0x11,0x00, //;75 K
:= 0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0x00, //;76 L
:= 0x11,0x1B,0x15,0x15,0x11,0x11,0x11,0x00, //;77 M
:= 0x11,0x19,0x15,0x13,0x11,0x11,0x11,0x00, //;78 N
:= 0x0E,0x11,0x11,0x11,0x11,0x11,0x0E,0x00, //;79 O
:= 0x1E,0x11,0x11,0x1E,0x10,0x10,0x10,0x00, //;80 P
:= 0x0E,0x11,0x11,0x11,0x15,0x12,0x0D,0x00, //;81 Q
:= 0x1E,0x11,0x11,0x1E,0x14,0x12,0x11,0x00, //;82 R
:= 0x0F,0x10,0x10,0x0E,0x01,0x01,0x1E,0x00, //;83 S
:= 0x1F,0x04,0x04,0x04,0x04,0x04,0x04,0x00, //;84 T
:= 0x11,0x11,0x11,0x11,0x11,0x11,0x0E,0x00, //;85 U
:= 0x11,0x11,0x11,0x11,0x11,0x0A,0x04,0x00, //;86 V
:= 0x11,0x11,0x11,0x15,0x15,0x1B,0x11,0x00, //;87 W
:= 0x11,0x11,0x0A,0x04,0x0A,0x11,0x11,0x00, //;88 X
:= 0x11,0x11,0x0A,0x04,0x04,0x04,0x0E,0x00, //;89 Y
:= 0x1F,0x01,0x02,0x04,0x08,0x10,0x1F,0x00, //;90 Z
:= .
:= .
:= .
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 13622
Tomi
Guest







Re: Char Generator in ROM
PostPosted: Sat Apr 12, 2003 1:57 am     Reply with quote

:=Is there an easier way of doing this without retyping 2Ks worth of the character generator.

I use this (for a graphic LCD, 8*6 dots each characters):
const char chrgen[450] = {
0x3E,0x51,0x49,0x45,0x3E,0x00, // 0
0x04,0x42,0x7F,0x40,0x00,0x00, // 1
0x62,0x51,0x49,0x49,0x46,0x00,
0x22,0x41,0x49,0x49,0x36,0x00,
0x18,0x14,0x12,0x79,0x10,0x00,
0x27,0x45,0x45,0x45,0x39,0x00,
0x3E,0x49,0x49,0x49,0x32,0x00,
0x01,0x61,0x19,0x05,0x03,0x00,
0x36,0x49,0x49,0x49,0x36,0x00,
0x26,0x49,0x49,0x49,0x3E,0x00, // 9
0x7E,0x11,0x11,0x11,0x7E,0x00, // A
0x7F,0x49,0x49,0x49,0x36,0x00,
0x3E,0x41,0x41,0x41,0x22,0x00,
0x7F,0x41,0x41,0x41,0x3E,0x00,
0x7F,0x49,0x49,0x41,0x41,0x00,
0x7F,0x09,0x09,0x01,0x01,0x00,
0x3E,0x41,0x49,0x49,0x3A,0x00,
0x7F,0x08,0x08,0x08,0x7F,0x00,
0x00,0x41,0x7F,0x41,0x00,0x00,
0x00,0x21,0x41,0x41,0x3F,0x00,
0x7F,0x08,0x14,0x22,0x41,0x00,
0x7F,0x40,0x40,0x40,0x40,0x00,
0x7F,0x02,0x04,0x02,0x7F,0x00,
0x7F,0x02,0x0C,0x30,0x7F,0x00,
0x3E,0x41,0x41,0x41,0x3E,0x00,
0x7F,0x09,0x09,0x09,0x06,0x00,
0x3E,0x41,0x41,0x61,0x7E,0x00,
0x7F,0x09,0x19,0x29,0x46,0x00,
0x26,0x49,0x49,0x49,0x32,0x00,
0x01,0x01,0x7F,0x01,0x01,0x00,
0x3F,0x40,0x40,0x40,0x3F,0x00,
0x1F,0x20,0x40,0x20,0x1F,0x00,
0x3F,0x40,0x38,0x40,0x3F,0x00,
0x41,0x26,0x18,0x26,0x41,0x00,
0x03,0x04,0x78,0x04,0x03,0x00,
0x61,0x51,0x49,0x45,0x43,0x00, // Z
0x30,0x4A,0x4A,0x4A,0x7C,0x00, // a
0x7F,0x48,0x48,0x48,0x30,0x00,
0x38,0x44,0x44,0x44,0x00,0x00,
0x30,0x48,0x48,0x48,0x7F,0x00,
0x3C,0x52,0x52,0x52,0x4C,0x00,
0x00,0x10,0xFE,0x11,0x01,0x00,
0x18,0xA4,0xA4,0xA4,0x7C,0x00,
0x7F,0x08,0x08,0x08,0x70,0x00,
0x00,0x40,0x7A,0x40,0x00,0x00,
0x00,0x40,0x84,0x7C,0x00,0x00,
0x7F,0x10,0x28,0x44,0x00,0x00,
0x00,0x00,0x3F,0x40,0x40,0x00,
0x7C,0x04,0x78,0x04,0x78,0x00,
0x7C,0x08,0x04,0x04,0x78,0x00,
0x38,0x44,0x44,0x44,0x38,0x00,
0xFC,0x24,0x24,0x24,0x18,0x00,
0x1C,0x22,0x22,0x22,0xFE,0x00,
0x7C,0x08,0x04,0x04,0x08,0x00,
0x48,0x54,0x54,0x54,0x24,0x00,
0x08,0x3F,0x48,0x40,0x00,0x00,
0x3C,0x40,0x40,0x40,0x3C,0x00,
0x1C,0x20,0x40,0x20,0x1C,0x00,
0x3C,0x40,0x38,0x40,0x3C,0x00,
0x44,0x28,0x10,0x28,0x44,0x00,
0x1C,0xA0,0xA0,0xA0,0x7C,0x00,
0x64,0x54,0x54,0x54,0x4C,0x00, // z
0x30,0x4A,0x4B,0x4A,0x7C,0x00, // á
0x3C,0x52,0x53,0x52,0x4C,0x00, // é
0x00,0x40,0x7B,0x40,0x00,0x00, // í
0x38,0x44,0x47,0x44,0x38,0x00, // ó
0x38,0x45,0x44,0x45,0x38,0x00, // ö
0x38,0x47,0x44,0x47,0x38,0x00, // ő
0x3C,0x40,0x43,0x40,0x3C,0x00, // ú
0x3C,0x41,0x40,0x41,0x3C,0x00, // ü
0x3C,0x43,0x40,0x43,0x3C,0x00, // ű
0x00,0x06,0x09,0x09,0x06,0x00, // °
0x00,0x00,0x60,0x60,0x00,0x00, // .
0x08,0x08,0x08,0x08,0x08,0x00 // -
0x00,0x00,0x00,0x00,0x00,0x00 // ' '
};

To access it:
void WriteChar(char be)
{
char i,bebe;
unsigned long idx;

switch (be) {
[skip; here are case statements for national characters]
default:
if (be < 0x3A) be -= 0x30;
else if (be <= 'Z') be -= 'A' - 10;
else if (be <= 'z') be -= 'a' - 36;
break;
}
idx = be;
idx *= 6;
for (i=0;i<6;i++) {
bebe = chrgen[idx++];
if (inverted) bebe = ~bebe; // black-on white or white-on-black
WriteDisplayData(bebe); // elementar graphic lcd_putc
}
}

For bigger characters I have a Windows program to save fonts in CCS C format. For example here is the array (for numbers only) of a 16-point Courier New font Smile (16*16 pixel characters):
const unsigned long bigchr[160] = {
0x0000,0x0000,0x0000,0x03F8,0x07FE,0x0E06,0x1803,0x1803,0x1803,0x1803,0x0C0E,0x0FFC,0x03F8,0x0000,0x0000,0x0000, // 0
0x0000,0x0000,0x0000,0x0006,0x1806,0x1806,0x1806,0x1FFF,0x1FFF,0x1800,0x1800,0x1800,0x0000,0x0000,0x0000,0x0000, // 1
0x0000,0x0000,0x0000,0x181C,0x1C1E,0x1E06,0x1B03,0x1B03,0x1983,0x18C3,0x18E6,0x187E,0x183C,0x0000,0x0000,0x0000, // 2
0x0000,0x0000,0x0000,0x0C00,0x1C06,0x1806,0x1803,0x1863,0x1863,0x1863,0x1CF7,0x0FFE,0x079C,0x0000,0x0000,0x0000, // 3
0x0000,0x0000,0x0000,0x0300,0x03C0,0x03F0,0x0338,0x1B1E,0x1B07,0x1FFF,0x1FFF,0x1B00,0x0000,0x0000,0x0000,0x0000, // 4
0x0000,0x0000,0x0000,0x0C00,0x0C7F,0x187F,0x1823,0x1833,0x1833,0x1833,0x1C73,0x0FE3,0x07C0,0x0000,0x0000,0x0000, // 5
0x0000,0x0000,0x0000,0x0000,0x03F0,0x0FFC,0x0CDE,0x1866,0x1867,0x1863,0x1CE3,0x0FC3,0x0783,0x0000,0x0000,0x0000, // 6
0x0000,0x0000,0x0000,0x0007,0x0007,0x0003,0x0003,0x1C03,0x1F83,0x07FB,0x007F,0x000F,0x0000,0x0000,0x0000,0x0000, // 7
0x0000,0x0000,0x0000,0x079C,0x0FFE,0x1CF7,0x1863,0x1863,0x1863,0x1863,0x1CF7,0x0FFE,0x079C,0x0000,0x0000,0x0000, // 8
0x0000,0x0000,0x0000,0x0000,0x183C,0x187E,0x18E7,0x18C3,0x1CC3,0x0CC3,0x0F66,0x07FE,0x01F8,0x0000,0x0000,0x0000 // 9
};



___________________________
This message was ported from CCS's old forum
Original Post ID: 13626
R.J.Hamlett
Guest







Re: Char Generator in ROM
PostPosted: Sat Apr 12, 2003 4:34 am     Reply with quote

:=I am currently have a 2K character generator in ROM using a 16F876 eg. below at end. I am only showing part of it. The code below lets me access the character fields (dots leds) to turn on leds of a display.
:=
:=If the character to display is 'A' Ascii 0x41, 65 decimal
:=
:=0x41 * 3 = 0xc3 = 195 dec. // 65th row of char gen.
:=add led row eg 3. // data for row 3
:=
:=chr_data_ptr = 198
:=
:=data returned would be 0x1f
:=
:=row 0 -> ... = 0x0e
:=row 1 -> . . = 0x11
:=row 2 -> . . = 0x11
:=row 3 -> ..... = 0x1f -> eg. data for above
:=row 4 -> . . = 0x11
:=row 5 -> . . = 0x11
:=row 6 -> . . = 0x11
:=row 7 -> = 0x00
:=
:= 0x0E,0x11,0x11,0x1F,0x11,0x11,0x11,0x00, //;65 A
:= ^ ^ ^ ^ ^
:= 195 196 197 198 199 ...
:=
:=char ChrGenData(char* char_data, char* led_row)
:={
:= chrgen_data_ptr = char_data;
:=
:= chrgen_data_ptr = (chrgen_data_ptr << 3); Mult x 8
:= chrgen_data_ptr = chrgen_data_ptr + led_row; // Add led row
:= chrgen_data_ptr = chrgen_data_ptr + CHRGEN_ADDR; // + 0x1700
:= return(read_program_eeprom(chrgen_data_ptr)); //get led data
:=}
:=
:=After all this I now want to implement this for the pic18F252.
:=
:=This would still work but since 18F is 16 bit the way that I have written the #rom statements will be very in-efficient on space used.
:=
:=
:=#ROM 0x1700 = {0x0E,0x11,0x11,0x1F,0x11,0x11,0x11,0x00}
:=
:=data in ROM would be starting at 0x1700
:=
:=00 0e, 00 11, 00 11, 00 1f, 00 11, 00 11, 00 11, 00 00 ->hex
:=
:=Hi byte of 16bit value always 00. in-efficient
:=
:=I found from a previous post this would work for me.
:=
:=#rom int8 0x1700 = { 0x0e }
:=#rom int8 0x1701 = { 0x11 }
:=#rom int8 0x1702 = { 0x11 }
:=#rom int8 0x1703 = { 0x1f }
:=#rom int8 0x1704 = { 0x11 }
:=#rom int8 0x1705 = { 0x11 }
:=#rom int8 0x1706 = { 0x11 }
:=#rom int8 0x1707 = { 0x0e }
:=
:=Is there an easier way of doing this without retyping 2Ks worth
:=of the character generator.
:=
:=Thanks in advance for any info given
:=
:=sorry for the long message post.
:=
:=Jerry
:=
:=
:=
:=//
:=///////////////////////////////////////////////////////////////
:=// CHARACTER GENERATOR
:=// 5X7 CHARACTERS IN A 6X8 CHARACTER FIELD
:=//////////////////////////////////////////////////////////////
:=//
:=
:=#ROM 0x1700 = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;0
:= 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;1
:= 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;2
:= 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;3
:= 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;4
:= .
:= .
:= .
:= 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;30
:= 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;31
:= 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, //;32
:= 0x04,0x04,0x04,0x04,0x04,0x00,0x04,0x00, //;33
:= 0x0A,0x0A,0x0A,0x00,0x00,0x00,0x00,0x00, //;34
:= 0x0A,0x0A,0x1F,0x0A,0x1F,0x0A,0x0A,0x00, //;35
:= 0x04,0x0F,0x14,0x0E,0x05,0x1E,0x04,0x00, //;36
:= 0x18,0x19,0x02,0x04,0x08,0x13,0x03,0x00, //;37
:= 0x08,0x14,0x14,0x08,0x15,0x12,0x0D,0x00, //;38
:= 0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00, //;39
:= 0x02,0x04,0x08,0x08,0x08,0x04,0x02,0x00, //;40
:= 0x08,0x04,0x02,0x02,0x02,0x04,0x08,0x00, //;41
:= 0x04,0x15,0x0E,0x1F,0x0E,0x15,0x04,0x00, //;42
:= 0x00,0x04,0x04,0x1F,0x04,0x04,0x00,0x00, //;43
:= 0x00,0x00,0x00,0x00,0x00,0x08,0x10,0x00, //;44
:= 0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00, //;45
:= 0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00, //;46
:= 0x00,0x01,0x02,0x04,0x08,0x10,0x00,0x00, //;47
:= 0x0E,0x11,0x13,0x15,0x19,0x11,0x0E,0x00, //;48 0
:= 0x04,0x0C,0x04,0x04,0x04,0x04,0x0E,0x00, //;49 1
:= 0x0E,0x11,0x01,0x06,0x08,0x10,0x1F,0x00, //;50 2
:= 0x0E,0x11,0x01,0x06,0x01,0x11,0x0E,0x00, //;51 3
:= .
:= .
:= .
:= 0x0E,0x11,0x01,0x0D,0x15,0x15,0x0E,0x00, //;64 @
:= 0x0E,0x11,0x11,0x1F,0x11,0x11,0x11,0x00, //;65 A
:= 0x1E,0x11,0x11,0x1E,0x11,0x11,0x1E,0x00, //;66 B
:= 0x0E,0x11,0x10,0x10,0x10,0x11,0x0E,0x00, //;67 C
:= 0x1E,0x11,0x11,0x11,0x11,0x11,0x1E,0x00, //;68 D
:= 0x1F,0x10,0x10,0x1E,0x10,0x10,0x1F,0x00, //;69 E
:= 0x1F,0x10,0x10,0x1E,0x10,0x10,0x10,0x00, //;70 F
:= 0x0F,0x10,0x10,0x13,0x11,0x11,0x0F,0x00, //;71 G
:= 0x11,0x11,0x11,0x1F,0x11,0x11,0x11,0x00, //;72 H
:= 0x0E,0x04,0x04,0x04,0x04,0x04,0x0E,0x00, //;73 I
:= 0x01,0x01,0x01,0x01,0x11,0x11,0x0E,0x00, //;74 J
:= 0x11,0x12,0x14,0x18,0x14,0x12,0x11,0x00, //;75 K
:= 0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0x00, //;76 L
:= 0x11,0x1B,0x15,0x15,0x11,0x11,0x11,0x00, //;77 M
:= 0x11,0x19,0x15,0x13,0x11,0x11,0x11,0x00, //;78 N
:= 0x0E,0x11,0x11,0x11,0x11,0x11,0x0E,0x00, //;79 O
:= 0x1E,0x11,0x11,0x1E,0x10,0x10,0x10,0x00, //;80 P
:= 0x0E,0x11,0x11,0x11,0x15,0x12,0x0D,0x00, //;81 Q
:= 0x1E,0x11,0x11,0x1E,0x14,0x12,0x11,0x00, //;82 R
:= 0x0F,0x10,0x10,0x0E,0x01,0x01,0x1E,0x00, //;83 S
:= 0x1F,0x04,0x04,0x04,0x04,0x04,0x04,0x00, //;84 T
:= 0x11,0x11,0x11,0x11,0x11,0x11,0x0E,0x00, //;85 U
:= 0x11,0x11,0x11,0x11,0x11,0x0A,0x04,0x00, //;86 V
:= 0x11,0x11,0x11,0x15,0x15,0x1B,0x11,0x00, //;87 W
:= 0x11,0x11,0x0A,0x04,0x0A,0x11,0x11,0x00, //;88 X
:= 0x11,0x11,0x0A,0x04,0x04,0x04,0x0E,0x00, //;89 Y
:= 0x1F,0x01,0x02,0x04,0x08,0x10,0x1F,0x00, //;90 Z
:= .
Fortunately yes.

The other post you mention, was dealing with data for the internal EEPROM. For the main chip memory, normal 'char' defines work fine. So you can define an ASCII message, as:

const char message[] = "This is a test"

and the compiler will correctly handle the one byte to two byte translation.
The same works with data tables, so:

const unsigned int conv[16] = {
0,10,20,30,40,50,60,70,80,90,90,90,90,90,90,90 };

will only use a single byte for each character (plus quite a few for the 'setup' to access them.
Also the actual access is quite efficient just using the normal 'conv[n]' instruction (on the 18F, this results in a 'table read', of the byte at address 'n'.
Seperately, I might consider trying declaring a union, and storing the data as:

typedef struct { int8 cline[8]; } fullc;
const fullc character[5] = {
0x0000000000000000,
0x0000000000000000, //;1
0x0000000000000000, //;2
0x0000000000000000, //;3
0x0000000000000000 //;4
};

union lines {
fullc word;
int8 b[8];
};

main() {
int8 oneline;
union lines onechar;
onechar.word=character[2];
oneline=onechar.b[0];

while (true);
}

Done like this, you can pull in an entire character as one access as 'character[n]'. This way, instead of doing eight seperate byte reads, the code knows to do a repeated transfer to move eight bytes.
Might be worth looking at. :-)

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 13627
Jerry.I
Guest







Re: Char Generator in ROM
PostPosted: Sat Apr 12, 2003 4:35 pm     Reply with quote

Thanks for Info;

I did not realize that I could make one large table.

I was thinking of the 16Fxxx limitations.

Thanks again.
___________________________
This message was ported from CCS's old forum
Original Post ID: 13631
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