View previous topic :: View next topic |
Author |
Message |
rtracy
Joined: 13 Oct 2005 Posts: 7
|
Help With Numbers |
Posted: Wed Apr 26, 2006 6:34 am |
|
|
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
|
|
Posted: Wed Apr 26, 2006 6:41 am |
|
|
The delay_x statements only take an 8 bit variable. They will take a 16-bit constant. |
|
|
rtracy
Joined: 13 Oct 2005 Posts: 7
|
|
Posted: Wed Apr 26, 2006 7:15 am |
|
|
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.
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
|
|
|
rtracy
Joined: 13 Oct 2005 Posts: 7
|
|
Posted: Thu Apr 27, 2006 3:42 pm |
|
|
Thanks!
|
|
|
|