![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
neil
Joined: 08 Sep 2003 Posts: 128
|
Compacting 7-bit ASCII into program mem to save space |
Posted: Mon Jul 07, 2003 4:39 am |
|
|
Hello all, I remember seeing someones neat algorithm for putting 2 ASCII chars into one word of program memory (14-bit), last year I think. I can't find this thread anywhere. If this person was you, could you please either point me to the thread, or re-post it. I neeed to save code space!!
I could probably work it out, but it would save time if I could just 'plagiarise'!!
Thanks in anticipation!
Neil.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515764 |
|
![](templates/subSilver/images/spacer.gif) |
jasonburns Guest
|
Re: VB program to convert text to 14bit rom code |
Posted: Mon Jul 07, 2003 5:03 am |
|
|
<font face="Courier New" size=-1>:=Hello all, I remember seeing someones neat algorithm for putting 2 ASCII chars into one word of program memory (14-bit), last year I think. I can't find this thread anywhere. If this person was you, could you please either point me to the thread, or re-post it. I neeed to save code space!!
:=
:=I could probably work it out, but it would save time if I could just 'plagiarise'!!
:=
:=Thanks in anticipation!
:=Neil.
G'day, I wrote a VB program to do just that. It takes a line of ascii
eg. ABCDEF
and converts it to
#rom 0xXXXX={0x20C2,0x21C4,0x22C6}
easy...
Here's a snippet of the code required to read it. I'll try and figure out how to attach the VB program. Here's the link
/* lcd msgs */
#org 0x0100, 0x01FF{}
#define LCD_MSGS 0x0100
//1234567890123456
// Note Exchange
#define LCDMSG_PWRUPMSG0 0x00
#rom 0x0100={0x104E,0x37F4,0x32A0,0x22F8,0x31E8,0x30EE,0x33E5,0x1020}
// V2.06
#define LCDMSG_PWRUPMSG1 0x01
#rom 0x0108={0x1020,0x1020,0x1056,0x192E,0x1836,0x1020,0x1020,0x1020}
// INSERT NOTES
#define LCDMSG_INSERTN 0x02
#rom 0x0110={0x1020,0x24CE,0x29C5,0x2954,0x104E,0x27D4,0x22D3,0x1020}
//FOR $20s & $10s
#define LCDMSG_FOR20 0x03
#rom 0x0118={0x234F,0x2920,0x1232,0x1873,0x1026,0x1024,0x18B0,0x39A0}
void
wr_lcd_line2(uchar x)
{
uchar u;
uint t;
/* wr lcd buffer with byte, with bytes stored in flash */
/* calc offset to msg (16 bytes per msg) */
t = x; /* get msg number */
t <<= 3; /* shift right by 3 bits */
t += LCD_MSGS; /* add offset to table in rom */
/* copy each byte to lcd_putchar() */
for (u = 0 ; u < 0x10 ; u++ )
{
/* first byte */
x = read_flash(t + u,0); /* extract first byte from 14bit word */
write_bank(3,lcd_line_ptr++,x); /* write it to storage area */
/* second byte */
x = read_flash(t + u,1); /* extract first byte from 14bit word */
write_bank(3,lcd_line_ptr++,x);
}
}
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515766 |
|
![](templates/subSilver/images/spacer.gif) |
neil
Joined: 08 Sep 2003 Posts: 128
|
Re: VB program to convert text to 14bit rom code |
Posted: Mon Jul 07, 2003 10:07 am |
|
|
Thanks Jason, that was exactly what I was looking for! I guess you don't mind me using your VB applet! It saves so much time working out the 14-bit words I didn't quite understand what you are doing with 'write_bank' Doesn't using this overwrite RAM that CCS has already used? Also, I guess that 'read_flash' is a function you have created? I have just used 'read_program_memory' instead and frigged about with the word to split it to 2x7-bit words. Not very tidy code, but it works.
Don't you find that "Thinking in binary" prevents you from thinking about normal things?! It's turning me into a bloody zombie!! Time to go home I think!
Thanks for your help,
Neil.
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515775 |
|
![](templates/subSilver/images/spacer.gif) |
jasonburns Guest
|
Re: VB program to convert text to 14bit rom code |
Posted: Mon Jul 07, 2003 9:23 pm |
|
|
:=Thanks Jason, that was exactly what I was looking for! I guess you don't mind me using your VB applet! It saves so much time working out the 14-bit words <img src="http://www.ccsinfo.com/pix/forum/smile.gif" border="0"> I didn't quite understand what you are doing with 'write_bank' Doesn't using this overwrite RAM that CCS has already used? Also, I guess that 'read_flash' is a function you have created? I have just used 'read_program_memory' instead and frigged about with the word to split it to 2x7-bit words. Not very tidy code, but it works.
:=
:=Don't you find that "Thinking in binary" prevents you from thinking about normal things?! It's turning me into a bloody zombie!! Time to go home I think!
:=
:=Thanks for your help,
:=Neil.
haha, i'm the opposite. I'm an old school ASM programmer and I have get into trouble if I'm NOT thinking binary or hex. ;)
Sorry bout the lack of comments. I was in a hurry at the time. All I was doing in the program was storing a series of 16 byte msgs that would later be displayed on an lcd (via i2c and another proccessor). I would pass the msg number to the function, read the string from rom, write it to an outgoing i2c buffer using the write_bank function. Later it would be sent to the lcd processor and displayed.
Don't treat this as gospel but, unless you tell it to use 16 bit pointers(by typing DEVICE PIC16F77 *=16), the ccs pcm compiler won't use ram banks 2 and 3. Therefore, using the write/read bank functions is ok in those banks. From memory, it also used far less code than allocating 16 bit pointers.
Glad to help you out. I might put some of my other PIC VB utilities online as well if they're useful.
cheers
Jason
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515782 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|