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

Resolution on tmr0

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



Joined: 08 Oct 2003
Posts: 11
Location: BRAZIL

View user's profile Send private message

Resolution on tmr0
PostPosted: Tue Jan 06, 2004 10:19 am     Reply with quote

Hi
I need your comments on this code...
Well... I need count time spend of complete signal. On this code i can only resolution in ms... I need resolution in us...but much better precision...


#include <16F84A.h>
#fuses XT, NOWDT, PUT
#use delay(clock=4000000)

byte ms;

#int_rtcc
clock_isr()
{
ms++;
}

void discarrega()
{
output_B(0x52);
if (input(PIN_A2) == 0 )
{
output_high(PIN_A3);
output_low(PIN_A3);
}

output_B(ms);
if (input(PIN_A2) == 0 )
{
output_high(PIN_A3);
output_low(PIN_A3);
}
}

void main()
{
set_timer0(231);

setup_timer_0(RTCC_INTERNAL | RTCC_DIV_4);
enable_interrupts(GLOBAL | INT_RTCC);

//setup_counters(RTCC_INTERNAL, RTCC_DIV_4 | RTCC_8_BIT);
//enable_interrupts(GLOBAL);
//enable_interrupts(INT_RTCC);

set_tris_B(0);

while (true)
{
if (!input(PIN_A0))
{
while (!input(PIN_A0));
set_timer0(231);
ms = 0;
while (input(PIN_A0));
while (!input(PIN_A0));
discarrega();
delay_ms(100);
}
}
}

thanks...
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: Resolution on tmr0
PostPosted: Tue Jan 06, 2004 11:35 am     Reply with quote

pitufos wrote:

output_high(PIN_A3);
output_low(PIN_A3);

This will not allow time for the pin to change state you should insert a pause.

What is you goal for the code to acomplish.
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