|
|
View previous topic :: View next topic |
Author |
Message |
vsmguy
Joined: 13 Jan 2007 Posts: 91
|
[SOLVED] Manipulating large arrays |
Posted: Wed Aug 12, 2009 10:55 am |
|
|
Using the PIC18F2550 (Has 32k Flash; 2k SRAM; 256byte EEPROM) @ 8MHz INTOSC.
I have to:
1. store large arrays with each having a uniq ID.
2. access them
3. they are to be processed by the same bit banging routine
Hence, what I did was to create a function that would do the bit banging.
This function would lookup the ID against the address of arrays and assign a pointer to the address.
This pointer would then be used by the bit banging routine that does not need to worry about the real address of the array anymore.
Code: |
#include <18F2550.h>
#fuses INTRC, NOWDT, PUT, BROWNOUT, NOLVP
#device CONST=ROM
#use delay(clock=8000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include <stdlib.h>
#include "Z:\\CMU\\Tukka\\norm\\c\\0.h"
#include "Z:\\CMU\\Tukka\\norm\\c\\1.h"
void main()
{
unsigned int16 ID = 0, size = 0, counter = 0;
const char *ptr = NULL; /* Points to memory address */
int8 t = 0;
setup_oscillator(OSC_8MHZ | OSC_INTRC); // 90% precision or 98%?
for(ID = 0; ID < 2; ++ID)
{
switch(ID)
{
case 0:
ptr = zero;
size = sizeof(zero);
break;
case 1:
ptr = one;
size = sizeof(one);
break;
}
printf("\r\nSize = %Lu bytes. Dump from %LX follows\r\n{", size, ptr); /* sizeof reports the correct size */
for(counter = 0; counter < size; ++counter)
{
t = ptr[counter];
printf("0x%X,", t);
}
printf("\b\b\r\n};\r\nDone.");
}
}
|
The did all the magic.
Here are snippets from,
#include "Z:\\CMU\\Tukka\\norm\\c\\0.h" :
const char zero[] =
{0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAA
,0xD5,0x52,0xAD,0x55,0x54,0xCD,0x55,0x52
,0xA9,0xAB,0x54,0x95,0x9D,0xA9,0x8C,0xD5
,0x6A,0xAA,0xA5,0x52,0xA9,0x29,0xBA,0xDC
,0xC6,0x55,0x55,0x6A,0xA9,0x55,0x52,0x95
..
#include "Z:\\CMU\\Tukka\\norm\\c\\1.h" :
const char one[] =
{0xAA,0xAA,0xAA,0xAA,0xAA,0xAA,0xAD,0x53
,0x52,0xD5,0x52,0xB5,0x54,0xAA,0xC9,0xAA
,0xA9,0x58,0xAF,0x45,0xAB,0x27,0x4B,0x4B
,0x4A,0xAA,0xA6,0xA5,0x4A,0xBE,0x1D,0x34
,0x6D,0x54,0xB5,0x55,0x55,0x54,0xAA,0x92
This raised a few questions however that I have created a new thread for.
(Why can't I attach files in this forum?)
Last edited by vsmguy on Fri Aug 14, 2009 12:49 am; edited 3 times in total |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 12, 2009 11:01 am |
|
|
Quote: | ** Error 97 "PCH_Test.c" Line 3(5,48): Must have a #USE DELAY before this #USE
*** Error 12 "PCH_Test.c" Line 25(24,28): Undefined identifier zero
*** Error 12 "PCH_Test.c" Line 26(30,34): Undefined identifier zero
*** Error 12 "PCH_Test.c" Line 30(24,27): Undefined identifier one
*** Error 12 "PCH_Test.c" Line 31(30,33): Undefined identifier one
*** Error 132 "PCH_Test.c" Line 35(70,73): STDOUT not defined (may be missing #USE RS232) ::
*** Error 132 "PCH_Test.c" Line 45(23,24): STDOUT not defined (may be missing #USE RS232) ::
*** Error 132 "PCH_Test.c" Line 48(32,33): STDOUT not defined (may be missing #USE RS232) :: |
Your program is not complete. It doesn't compile.
Quote: | I had a look at the solution by PCM Programmer, |
Post a link to this previous example. |
|
|
vsmguy
Joined: 13 Jan 2007 Posts: 91
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 12, 2009 9:09 pm |
|
|
Quote: | *** Error 12 "PCH_Test.c" Line 25(24,28): Undefined identifier zero
*** Error 12 "PCH_Test.c" Line 26(30,34): Undefined identifier zero
*** Error 12 "PCH_Test.c" Line 30(24,27): Undefined identifier one
*** Error 12 "PCH_Test.c" Line 31(30,33): Undefined identifier one
Does it compile now?
|
You're still missing the declarations for 'zero' and 'one'. |
|
|
vsmguy
Joined: 13 Jan 2007 Posts: 91
|
|
Posted: Thu Aug 13, 2009 12:11 pm |
|
|
PCM programmer wrote: |
You're still missing the declarations for 'zero' and 'one'. |
They are very large arrays - around 400 bytes each.
I wanted to upload these to the forum but can't find anything to help me do that.
Should I upload the files to some filesharing site and post the link here?
Which filesharing site? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 13, 2009 1:02 pm |
|
|
Just post the declaration and the first line of initialization data
for each array. That will be enough. |
|
|
vsmguy
Joined: 13 Jan 2007 Posts: 91
|
|
Posted: Thu Aug 13, 2009 4:54 pm |
|
|
Done! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
vsmguy
Joined: 13 Jan 2007 Posts: 91
|
|
Posted: Thu Aug 13, 2009 7:10 pm |
|
|
Extremely insightful. Will update the thread in a few hours. |
|
|
|
|
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
|