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

stdarg.h and variable parameters

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



Joined: 20 Dec 2006
Posts: 40
Location: Reading, UK

View user's profile Send private message

stdarg.h and variable parameters
PostPosted: Wed Jan 10, 2007 3:15 am     Reply with quote

I'm trying to implement a subroutine that calls a variable number of arguments.

The routine is in the form scroll(9, 55, 55, 16, 36, 36, 31, 36, 55, 55); where the 9 denotes the number of variables, and the susbequent variable are all values within an array. The routine will take the first varaible (55 in this case) look it up in an array called led_map[] and return a hex value to ouput to my 7-segment display.

Now this is fine, I'm getting something output to my display, however, I only ever seem to load the first variable.
Code:
void scroll(int a, ...)
{
   char c;
   va_list al;
   va_start(al, a);
   while(a--)
   {
      if(scrollcount == 124)
      {
         c = va_arg(al, char);
         segs(seg_2, seg_3, c);
         scrollcount = 0;
      }
   }
   va_end(al);
}

The code should take the variable, and display it on the right hand segment of the 3 digit 7-segment display, whilst shunting the display one character to the left, to present a scrolling effect.

I have an interrupt that reads the locations of seg_1, seg_2 and seg_3 for the current output character every 250 us or so. The IF loop is in there to slow down the updates to the memory locations, so that it doesn't update it quickly and essentially show the final character.

This is with PCM 4.016 and for a 16F914 pic.

Can anyone show me where I've gone wrong? Additionally, when i compile it, I get a >>> Warning 207 Line 138(1,1): Code has no effect, referring to the line just after the final subroutine } bracket.

CCS Technical Support does not monitor this forum on a regular basis. Please do not post bug reports to this form. All bug reports should be emailed to support@ccsinfo.com. Thank you.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Wed Jan 10, 2007 3:39 am     Reply with quote

First, the V4.xxx compiler versions up till now are all to be considered beta versions. I'm sorry to say so, but knowledge from the past major compiler upgrades learns us that it will take about 6 more months for CCS to release a stable compiler version.

Variable arguments are a new functionality in the V4.xx compiler. Like most new features at the current state it will contain bugs.

The most recent stable compiler version is v3.249 and I recommend you to use this unless you want to spend a lot of time searching for compiler bugs.

Second, when reporting problems make sure the problem still exists in the most recent compiler version. V4.016 is old, current version is 4.020. CCS provides the service to send you an email when new compiler versions are released http://www.ccsinfo.com/newsletters.php
aodj



Joined: 20 Dec 2006
Posts: 40
Location: Reading, UK

View user's profile Send private message

PostPosted: Wed Jan 10, 2007 3:56 am     Reply with quote

Old? Crikey, I only got it at the end of November!
Ttelmah
Guest







PostPosted: Wed Jan 10, 2007 6:00 am     Reply with quote

Normally, that would make it fairly new. However, the key is that V4, has only just been 'launched', and CCS, have a really annoying habit, of effectively doing their beta testing on the customers!. While this is happening, new versions appear every few _days_...
Currently, the latest releases of V4, are just about competitive with V3.249, using only 'V3' features. So far I have yet to find a 'new' (V4) feature that fully works. Some are just starting to show signs that they are getting close.
If you have a look in the code forum, there is a method shown for doing a sscanf (Ithink), using a 'work round', of passing a string containing the multiple values. While not perfect, this works, and if you pull 3.249, it'll get you going till a V4 version starts to really work...

Best Wishes
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