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

Conditional Expression operator ?:
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
dyeatman



Joined: 06 Sep 2003
Posts: 1914
Location: Norman, OK

View user's profile Send private message

PostPosted: Fri Nov 04, 2005 8:56 pm     Reply with quote

With arrays that size you are going to run into additional problems due to bank size (96) on the 16F series chips. You will either have to work around the bank size problem (there are lots of posts in this forum about the subject) or you might want to look at using the drop in replacement 18F series that eliminates the bank problem.
amcasi



Joined: 19 Jun 2015
Posts: 21
Location: Banned - Spammer

View user's profile Send private message

Good explanation
PostPosted: Tue Oct 15, 2019 4:24 am     Reply with quote

Many many thanks to you for your good explanation. I could not find that explanation in the CCS_Manual.pdf. It must be there. I am looking here 2 times.
Thanks a lot
Huseyin

Anonymous wrote:
Code:

#device *=16
#include<stdlib.h>

#FUSES XT, NOPROTECT, NOWDT, NOLVP, NOBROWNOUT

#use Delay(clock = 4000000)

#include "lcdDriver.c"
#include "codes.c"

void main()
{
   int i;

   for(i = 0; i < 30; i++)
   {
      printf(lcd_putch, "%d: %s\n", i, i < 16 ? codes0[i] : codes1[i - 16]);
      delay_ms(1000);
   }
}


codes.c contains two arrays of strings (codes0 and codes1).

I appreciate you taking the time to help.
Ttelmah



Joined: 11 Mar 2010
Posts: 19257

View user's profile Send private message

PostPosted: Tue Oct 15, 2019 9:40 am     Reply with quote

First comment. You can make your const arrays work, by adding the
instruction:

#device PASS_STRINGS=IN_RAM

Just after the processor include line.

Understanding this is a key feature of the PIC. Unlike 99% of other
processors, the PIC has the ROM as a completely separate memory space
to the RAM. So there are two address '0's, one in ROM and one in RAM.
A 'pointer', is inherently a RAM address, so const arrays won't work with
'pointers'.

The PASS_STRINGS option tells the compiler to create 'virtual' pointers
to strings stored as const's.

Then the ?: syntax, normally requires the test parameter to be in
brackets. Depending on the line being used, this is _required_ to make
the parsing work. Forcing this to be evaluated before the next statements.

((i < 16) ? codes0[i] : codes1[i - 16])

I'd probably also bracket the whole entity as well to ensure that the
printf sees it as a single value.

However 'PASS_STRINGS' requires a reasonably recent compiler.
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