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

Why not work

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







Why not work
PostPosted: Thu Aug 05, 2004 6:13 am     Reply with quote

when i use pin_c0 show led by this code but pin_c0 is light all the time.
but when i use timer0 for change value in pin_c1. Pin_c0 is not light all the time but it blink like pin_c0-->on and off.Why?
===============================================

#include <16F877.h>
#device *=16
#device adc=10
#use delay(clock=4000000,RESTART_WDT)
#fuses NOWDT,XT, PUT, NOPROTECT, BROWNOUT, NOLVP, NOCPD, NOWRT, NODEBUG

#ZERO_RAM

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

#define RS PIN_E0
#define RW PIN_E1
#define EN PIN_E2

#define leddison output_high(pin_c0)
#define leddisoff output_low(pin_c0)

char tmpshow[20];
int resetch1=0;

#int_TIMER0
TIMER0_isr()
{
if (resetch1==1)
{
output_high(pin_c1);
}
else
{
output_low(pin_c1);
}
}

void main()
{

int checkdisend=1;
long valueadc;
int sdis=0;

port_b_pullups(TRUE);
setup_adc_ports(A_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_counters(RTCC_INTERNAL,RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);

// enable_interrupts(INT_TIMER0); <====when i comment this line it work but when i not comment this line it error.
// enable_interrupts(GLOBAL); <====when i comment this line it work but when i not comment this line it error.

while(1)
{
set_adc_channel( 0 );
delay_ms(10);
valueadc = Read_ADC();

if (valueadc<=55)
{
resetch1=1;
}
else
{
resetch1=0;
}

if(!input(pin_b2))
{
checkdisend=0;
}

if( input(pin_b3)) //ถ้ายังไม่มีถ่านหรือว่า Discharge เสร็จแล้ว เป็น 1
{
output_low(pin_b4);
checkdisend=1;
leddisoff;
delay_us(10);
sdis=0;
}
else //ถ้า discharge ยังไม่เสร็จ เป็น 0
{
if(checkdisend==0)
{
output_high(pin_b4);
leddison;
delay_ms(500);
sdis=1;
checkdisend==0;
}
else
{
leddisoff;
delay_ms(500);
output_low(pin_b4);
checkdisend=1;
sdis=0;
}
}
}
}
Guest








PostPosted: Thu Aug 05, 2004 7:01 am     Reply with quote

checkdisend is always 1 so only leddisoff is called.
Maybe you'd want to write:
checkdisend=0;
instead of :
checkdisend==0;
in the "if(checkdisend==0) " branch.
a
Guest







a
PostPosted: Thu Aug 05, 2004 8:49 am     Reply with quote

thank you for your answer. But i recompile program. it have the same error. can i use pin_c0 and pin c1 seperate like output_high(pin_c0) or another but when i use c1. output of c0 is change it blink on off on off
but when i am not use pin c1. it ok pin c0 is light all the time until input(pin_b3)=1.
anyone can help me. Please.
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