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

Help With Numbers

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



Joined: 13 Oct 2005
Posts: 7

View user's profile Send private message

Help With Numbers
PostPosted: Wed Apr 26, 2006 6:34 am     Reply with quote

This version works just fine for making a test pulse.

Code:
#use delay(clock=4000000)
int y;
int16 low,high;

void main()
{

   setup_adc_ports(AN0);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);


y=1;

while (y=1) {

  high = 1;
  low = 19;

  output_high(pin_d5);
  delay_ms(high);
  output_low(pin_d5);
  delay_ms(low);
                  }

}


This version doesn't seem to pass more than 8 bits. I've tried various specifiers but I'm still missing something. So how do I pass a large number? Thanks for any help.


Code:
#use delay(clock=4000000)
int y;
int16 low,high;

void main()
{

   setup_adc_ports(AN0);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);


y=1;

while (y=1) {

  high = 1000;
  low = 19000;

  output_high(pin_d5);
  delay_us(high);
  output_low(pin_d5);
  delay_us(low);
                  }

}
rberek



Joined: 10 Jan 2005
Posts: 207
Location: Ottawa, Canada

View user's profile Send private message

PostPosted: Wed Apr 26, 2006 6:41 am     Reply with quote

The delay_x statements only take an 8 bit variable. They will take a 16-bit constant.
rtracy



Joined: 13 Oct 2005
Posts: 7

View user's profile Send private message

PostPosted: Wed Apr 26, 2006 7:15 am     Reply with quote

rberek wrote:
The delay_x statements only take an 8 bit variable. They will take a 16-bit constant.


Thanks, Rberek. Reading the manual is key. Smile

I was trying to take a value directly from the 10bit ADC and drop it into a delay statement.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Apr 26, 2006 1:46 pm     Reply with quote

See this thread for the long_delay_us() function:
http://www.ccsinfo.com/forum/viewtopic.php?t=16656&start=1
rtracy



Joined: 13 Oct 2005
Posts: 7

View user's profile Send private message

PostPosted: Thu Apr 27, 2006 3:42 pm     Reply with quote

Thanks!

PCM programmer wrote:
See this thread for the long_delay_us() function:
http://www.ccsinfo.com/forum/viewtopic.php?t=16656&start=1
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