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

pic16f628a/ values float hex

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







pic16f628a/ values float hex
PostPosted: Mon Feb 25, 2008 6:37 am     Reply with quote

Hi folks.
I am using the pic 16f628a for servos and I found one way to create 1.0 ms Hi and 20 ms low.
This way:
Code:

#include<16f628a.h>

#fuses NOWDT,NOPROTECT,PUT,NOLVP,MCLR,INTRC_IO

#use delay(clock=4000000)
#use fast_io(b)
#use fast_io(a)
#define high 0x01
#define low 0x14

void main()
{
int duty ;
duty=high;
set_tris_b(0xFE);

while(1)
  {
   output_low(pin_b0);
   output_high(pin_b0);
   delay_ms(duty);
   output_low(pin_b0);
   delay_ms(low);
   duty=duty+1;
  }

}

I can increase the duty cycle and it is good for me.
I would like to do high with value 1.5 in hexadecimal.
is it possible?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 25, 2008 11:15 am     Reply with quote

No. But you could use the delay_us() function instead of delay_ms().
Then you can pass it a parameter (int16) of 1500. A delay of 1500 us
is the same as 1.5 ms.
alex
Guest







PostPosted: Mon Feb 25, 2008 8:29 pm     Reply with quote

thanks, PCM programmer.
I will test your sugestion.
And I will post here the result.
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