Searching \ for '[pic]: c code pointer test code' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/languages.htm?key=c
Search entire site for: 'c code pointer test code'.

Exact match. Not showing close matches.
PICList Thread
'[pic]: c code pointer test code'
2003\02\26@193829 by Andre Abelian

picon face
Hi to all engineers,

I am worked on simple c code to test pointer
I am not sure why it doesn't work

// pointer test
void pointer_test(void){
unsigned char c;
unsigned char index;
unsigned char const PATTERN[]={1,2,4,8,16,32,64,128};
index=0;
for(c=8;c!=0;c--)
{
PORTB=PATTERN[index];
index++;
}
}

I am sure if this is how I suppose to use pointer
In hi-tech. any help will appreciate


Andre

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\26@195535 by John Dammeyer

flavicon
face
Hi,

Arrays in C start at 0 and go to size-1.

You'd be better off writing the loop like this.

for(c=0; c<8; c++) {
   PORTB=PATTERN[c];
}

John Dammeyer

Wireless CAN with the CANRF module now available.
http://www.autoartisans.com/products
Automation Artisans Inc.
Ph. 1 250 544 4950


> {Original Message removed}

2003\02\27@035812 by hael Rigby-Jones

picon face
{Quote hidden}

This looks OK, compiles OK and works fine in the MPLAB simulator, what is
the actual problem you are seeing?  Are you initialising TRISB as outputs?

Regards

Mike


=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================
Any questions about Bookham's E-Mail service should be directed to postmasterspamKILLspambookham.com.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2003\02\27@035820 by hael Rigby-Jones

picon face
       > -----Original Message-----
       > From: pic microcontroller discussion list
       > [.....PICLISTKILLspamspam.....MITVMA.MIT.EDU] On Behalf Of Andre Abelian
       > Sent: Wednesday, February 26, 2003 4:40 PM
       > To: EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU
       > Subject: [pic]: c code pointer test code
       >
       >
       > Hi to all engineers,
       >
       > I am worked on simple c code to test pointer
       > I am not sure why it doesn't work
       >
       > // pointer test
       > void pointer_test(void){
       > unsigned char c;
       > unsigned char index;
       > unsigned char const PATTERN[]={1,2,4,8,16,32,64,128};
       > index=0;
       > for(c=8;c!=0;c--)
       > {
       > PORTB=PATTERN[index];
       > index++;
       > }
       > }
       >
       >  I am sure if this is how I suppose to use pointer
       >  In hi-tech. any help will appreciate
       >
       >
       > Andre
       >
       > --
       > http://www.piclist.com hint: PICList Posts must start with ONE
topic:
       > [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]:
->Ads


{Quote hidden}

John,

I took one look at the code and started writing the same reply, but if you
look again he's not using the loop counter to index the array, there is a
separate variable used for this and the code works perfectly.

Regards

Mike


=======================================================================
This e-mail is intended for the person it is addressed to only. The
information contained in it may be confidential and/or protected by
law. If you are not the intended recipient of this message, you must
not make any use of this information, or copy or show it to any
person. Please contact us immediately to tell us that you have
received this e-mail, and return the original to us. Any use,
forwarding, printing or copying of this message is strictly prohibited.
No part of this message can be considered a request for goods or
services.
=======================================================================
Any questions about Bookham's E-Mail service should be directed to KILLspampostmasterKILLspamspambookham.com.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

More... (looser matching)
- Last day of these posts
- In 2003 , 2004 only
- Today
- New search...