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 CCS Technical Support

things i do not know , of which there are many - here are 2

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

things i do not know , of which there are many - here are 2
PostPosted: Wed Jun 03, 2015 2:10 pm     Reply with quote

I'm trying to improve a storage efficent data structure using
an INT1 sparse array to record fault states in 1536 different
addressable locations.
presently the results of a scan are stored in this:

INT1 missing[96][16]

which fits in 192 BYTES of an 18F4620 PIC

at start of a 'run' all elements set to 0. With nested loops. ;-((

Then , When external devices are scanned a single array element at

missing[address][excite]=1;

is set true if one of 96 addresses when cross tested by
one of 16 line-exciters is not responding.

After a complete 1536 scan, only a very few or sometimes NONE of the bits will be set in 'missing[][]'

Without using nested loops i'd like to be able to also view the 1536
locations as 192 bytes , testing each byte for non-zero and THEN decoding
what actual bit is "it" with a bit of bit-shifting.

I'd also like to be able to RAPIDLY rezero the 192 bytes without loops too.

Ideally i would aim a pointer somewhere and stuff++ 192 ASCIIZ's
down it's throat ;-))

I have not figured out the appropriate structure to do it with.
Ideas welcome.
-------
And then there is this:

I ONLY use the command line.

I have long wanted to add a default alternative
at compile time for code libraries of my own
outside the current project folder and outside the CCS mothership
version folder as well

i have struck out completely with making
I=" path data ......"
work by creating a like named .PJT or .CCSPJT file with the
prefix of my source that contains

I="C:\....path ......;" line in it.

Is there a known "works in the source file itself " compiler directive
that basically does an
I+=" more path info;"
type of function in my source file header right at line #1 ??

so i can ADD to the CCS intrinsics ??
and not replace it ?
Is there such a directive i can add to my source file ?

I just can't locate it , if it is real .
Ttelmah



Joined: 11 Mar 2010
Posts: 19499

View user's profile Send private message

PostPosted: Wed Jun 03, 2015 2:26 pm     Reply with quote

Union.....
Or use #byte.

So:
Code:

union {
   int1 missing[96][16];
   int8 b[192];
} data;


data.missing[x][y] accesses the bits just as missing does, but data.b[n] accesses the bytes.

This is generic C, as opposed to any 'special' CCS feature. The next is an alternative CCS way of doing this:
Code:

int1 missing[96][16];
int8 b[192];
#byte b=missing //this locates 'b' into the same memory space as missing


One of the features of #byte, is that if called with an already declared variable, it locates this at the given address. In this case the address of 'missing'.

On zeroing, memset:
Code:

memset(b,0,192);


Using the byte declarations, will set all 192 bytes to zero.

Use the PATH.

Have a .CMD file to set his so the default search location at the start is where you want.
Do your compile.
Reset PATH
jeremiah



Joined: 20 Jul 2010
Posts: 1345

View user's profile Send private message

PostPosted: Wed Jun 03, 2015 2:41 pm     Reply with quote

EDIT: Just saw I was beaten to the punch but anyways I was gonna say:

Code:

#case
#include <24EP512GU810.h>

typedef struct{
   int8 b0 : 1;
   int8 b1 : 1;
   int8 b2 : 1;
   int8 b3 : 1;
   int8 b4 : 1;
   int8 b5 : 1;
   int8 b6 : 1;
   int8 b7 : 1;
} bits_t;

typedef union{
   int1 missing[96][16];
   unsigned int8 bytes[192];
   bits_t bits[192];
} view_t;

view_t view;

void main()
{

   view.missing[0][0] = 1;
   view.bytes[1] = 0x23;
   view.bits[2].b1 = 1;
   memset(&view,0,sizeof(view_t));
}




LST file results:
Code:

....................    view.missing[0][0] = 1;
00288:  BSET.B  1000.0
....................    view.bytes[1] = 0x23;
0028A:  MOV.B   #23,W0L
0028C:  MOV.B   W0L,1001
....................    view.bits[2].b1 = 1;
0028E:  BSET.B  1002.1
....................    memset(&view,0,sizeof(view_t));
00290:  MOV     #1000,W1
00292:  MOV     #0,W2
00294:  REPEAT  #BF
00296:  CLR.B   [W1++]


Nothing new new though as Ttelmah already covered that.

That's with 5.044

EDIT: sorry still had my pic24 in there, here is the output for yours
Code:

....................    view.missing[0][0] = 1;
00030:  BSF    04.0
....................    view.bytes[1] = 0x23;
00032:  MOVLW  23
00034:  MOVWF  05
....................    view.bits[2].b1 = 1;
00036:  BSF    06.1
....................    memset(&view,0,sizeof(view_t));
00038:  CLRF   FEA
0003A:  MOVLW  04
0003C:  MOVWF  FE9
0003E:  CLRF   00
00040:  CLRF   02
00042:  MOVLW  C0
00044:  MOVWF  01
00046:  BRA    0004


Last edited by jeremiah on Wed Jun 03, 2015 4:18 pm; edited 1 time in total
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Wed Jun 03, 2015 3:10 pm     Reply with quote

Thanks for the assist to you both.

I don't mind admitting ignorance, but i try hard not to be wrong. Very Happy
Your generosity with good advice is much appreciated

-d-
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