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

Set PWM on interrupt?
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 11, 2010 12:28 am     Reply with quote

Make a test program similar to this, and see if you can display the
first and last elements in the array.
Code:

#include <18F2620.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

const char okay[5399]={
0x39, 0x26, 0x26, 0x26, 0x26, 0x51, 0x77, 0x8C, 0x7C, 0x85, 0xB2, 0xDA, ...
.
.
.

};


//======================================
void main(void)
{

int16 i;
int8 c;

// Display first element.
i = 0;
c = okay[i];
printf("%X ", c);

// Display last element.
i = 5398;
c = okay[i];
printf("%X ", c);


while(1);
}
 
RoGuE_StreaK



Joined: 02 Feb 2010
Posts: 73

View user's profile Send private message

PostPosted: Thu Feb 11, 2010 12:43 am     Reply with quote

I don't actually have a working rs232 setup yet, so can't trace out anything, hoping to get one operational over the weekend.
RoGuE_StreaK



Joined: 02 Feb 2010
Posts: 73

View user's profile Send private message

PostPosted: Thu Feb 11, 2010 6:50 am     Reply with quote

Hmm, just tried a different method of "tracing" and looks like the problem's uncovered, but I have no idea how to get around it;

Instead of outputing the array values via serial, I thought I'd check the values by lighting an LED if they were true;
Code:
      if(sndLoop1[0] == "0x86") output_bit(PIN_A1, 1);
      if(sndLoop1[12088] == "0x73") output_bit(PIN_A3, 1);

(sndLoop1 being a new sound loop, with 12089 values, first being "0x86", last being "0x73")

But that didn't compile, came up with an error for the second line "Subscript out of range" Sad
According to the help file, "A subscript to a RAM array must be at least 1 and not more than 128 elements. Note that large arrays might not fit in a bank. ROM arrays may not occupy more than 256 locations."
So, looks like I have to figure out a way of spliiting my arrays so that each sub-section has no more than 128 elements in them? I haven't seen any examples anywhere that have come across this issue, any tips on where to start looking for a solution?

[EDIT] just tried splitting a small section into a multidimensional array, const char sndLoop1[11][128], 11 elements with 128 variables in each, but got the errors "Too may subscripts". So now I'm more stumped than Stumpy McStump at a stumping convention Confused
Code:
const char sndLoop1[11][128]={
{
0x86,0x93,0x9D,0xA7,0xAE,0xB4,0xB9,0xBE,0xC2,0xC6,0xCA,0xCE,0xD2,0xD5,0xD8,0xDB,
0xDE,0xE1,0xE4,0xE6,0xE8,0xEA,0xED,0xEE,0xF0,0xF2,0xF3,0xF4,0xF6,0xF7,0xF8,0xF8,
0xF9,0xFA,0xFA,0xFB,0xFC,0xFC,0xFC,0xFC,0xFD,0xFD,0xFD,0xFD,0xFD,0xFD,0xFD,0xFD,
0xFD,0xFD,0xFC,0xFC,0xFC,0xFB,0xFB,0xFA,0xF9,0xF9,0xF8,0xF7,0xF6,0xF5,0xF3,0xF2,
0xF1,0xEF,0xED,0xEB,0xE9,0xE7,0xE4,0xE2,0xDF,0xDC,0xD9,0xD6,0xD2,0xCF,0xCB,0xC7,
0xC3,0xBF,0xBA,0xB5,0xAF,0xA8,0x9F,0x96,0x87,0x73,0x68,0x5E,0x56,0x4F,0x4A,0x45,
0x40,0x3C,0x38,0x34,0x30,0x2D,0x29,0x26,0x23,0x20,0x1E,0x1B,0x19,0x17,0x14,0x12,
0x11,0x0F,0x0D,0x0C,0x0B,0x09,0x09,0x08,0x07,0x06,0x05,0x05,0x04,0x04,0x04,0x03
},{
0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x04,0x04,0x05,0x05,
0x06,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0E,0x0F,0x11,0x13,0x15,0x17,0x19,0x1B,
0x1E,0x21,0x23,0x27,0x2A,0x2D,0x31,0x34,0x38,0x3C,0x41,0x45,0x4A,0x50,0x57,0x5F,
0x69,0x76,0x87,0x95,0x9F,0xA8,0xAF,0xB5,0xBA,0xBE,0xC3,0xC7,0xCB,0xCF,0xD2,0xD6,
0xD9,0xDC,0xDF,0xE2,0xE4,0xE7,0xE9,0xEB,0xED,0xEF,0xF1,0xF2,0xF4,0xF5,0xF6,0xF7,
0xF8,0xF9,0xF9,0xFA,0xFB,0xFB,0xFC,0xFC,0xFC,0xFD,0xFD,0xFD,0xFD,0xFD,0xFD,0xFD,
0xFD,0xFD,0xFD,0xFD,0xFC,0xFC,0xFC,0xFB,0xFB,0xFA,0xF9,0xF9,0xF8,0xF7,0xF6,0xF4,
0xF3,0xF2,0xF0,0xEE,0xEC,0xEA,0xE8,0xE6,0xE3,0xE1,0xDE,0xDB,0xD8,0xD5,0xD1,0xCE
},{
0xCA,0xC6,0xC2, etc...


Any help or pointers would be greatly appreciated, none of the info on sound playback I've come across ever mentioned issues with large arrays, so I dunno what they were doing differently...

PS. I also tried changing the CONST to ROM in both forms of the array, but it appeared to make no difference at all.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 11, 2010 2:24 pm     Reply with quote

Quote:
According to the help file, "ROM arrays may not occupy more than 256 locations."

But that's for 16F-series PICs, with the PCM compiler.

The PCH compiler allows much larger ROM ('const') arrays. I don't know
the limit, but it's much larger than 256 bytes.
RoGuE_StreaK



Joined: 02 Feb 2010
Posts: 73

View user's profile Send private message

PostPosted: Thu Feb 11, 2010 5:10 pm     Reply with quote

I'm reasonably happy to split up the array, I've found a new method of creating the files that should make splitting them up much easier, but any thoughts on the error I got when I tried using a split array? I thought I did it in the same manner as other examples I found on the forum?

It's no issue to split the arrays into 16 values, 128 values, whatever; well, it's actually easiest to split into 16 value sections, as I can just do a search and replace at the end of each line (each line has 16 values in it), or I can manually go through and split on every 8th line (8x16 = 128) or 16th line (16x16 = 256).
As you say though, It's an 18F, and it would appear to me to definitely be referencing more than 256 values before it "spits the dummy". Splitting is fine by me, just seems I'm referencing it wrong or declaring it wrong, as I now get the new error "Too may subscripts", which according to the help file means my referencing doesn't match my declaration, or my declaration doesn't match the actual array?
RoGuE_StreaK



Joined: 02 Feb 2010
Posts: 73

View user's profile Send private message

PostPosted: Fri Feb 12, 2010 12:10 am     Reply with quote

After lots of searching I'm even more confused; For example, the post at http://www.ccsinfo.com/forum/viewtopic.php?t=37200 seems to be doing a similar thing but to hold a bmp graphic in memory rather than sound, they say they've declared as
Code:
const int8 imagen[64][16]
but to me the structure looks like it's
Code:
const int8 imagen[128][8]
?? Looks like they had success with a large array, so what am I doing wrong?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 12, 2010 2:14 pm     Reply with quote

The problem is that you have made so many different attempts, and
so many previous posts marked with [EDIT], that I don't know what
your current status is. Post a test program that is currently not working.
Post your compiler version.
Guest








PostPosted: Mon Feb 15, 2010 6:56 am     Reply with quote

I seem to have things working now, I've had to create the sounds as multidimensional arrays inline in the main .c file, maybe I was doing it wrong but seemed it wouldn't work when they were externalised in their own files. Seems to be playing the sounds right through now, but I haven't done extensive testing and my rs232 interface still isn't working, so I'll post back my results when I have a definitive version.
One sound is about 13000 samples long, in a roughly 800 x 16 array, tried multiple layouts and seems the method that works (for me) is each node is simply on a new line without a comma delimiter on the end of the previous line, and no brackets to delineate nodes

ie.
Code:
const char sndLoop1[800][16]={
{
0x86,0x93,0x9D,0xA7,0xAE,0xB4,0xB9,0xBE,0xC2,0xC6,0xCA,0xCE,0xD2,0xD5,0xD8,0xDB
0xDE,0xE1,0xE4,0xE6,0xE8,0xEA,0xED,0xEE,0xF0,0xF2,0xF3,0xF4,0xF6,0xF7,0xF8,0xF8

...

0xF9,0xFA,0xFA,0xFB,0xFC,0xFC,0xFC,0xFC,0xFD,0xFD,0xFD,0xFD,0xFD,0xFD,0xFD,0xFD
}
RoGuE_StreaK



Joined: 02 Feb 2010
Posts: 73

View user's profile Send private message

PostPosted: Mon Feb 15, 2010 4:44 pm     Reply with quote

Didn't realise I wasn't signed in. Obviously that last post was from me.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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