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

16F505 Problem

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








16F505 Problem
PostPosted: Sat May 05, 2007 6:15 am     Reply with quote

Hi.
I want to use 16f505 but my code can not work. Would you help me please ? I want to use Timer0 and only one led flasher. Best regards.
Code:

#include <16F505.h>
#FUSES NOWDT, INTRC_IO, NOMCLR
#use delay(clock=4000000)


#define  Led       PIN_B1

void main()
{
   int X=0;
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4);  //1ms timer
   set_tris_b(0b00);
   set_tris_c(0x00);
   while (true)
     {
       set_timer0(0);
       Output_high(PIN_B1);
       Delay_ms(1000);
       Output_low(PIN_B1);
       Delay_ms(1000);
       get_timer0();     
       output_c(X);
      }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun May 06, 2007 4:19 pm     Reply with quote

Quote:

My code can not work:
get_timer0();
output_c(x);

You need to put the value from get_timer0() into X.

Do it like this:
Quote:

x = get_timer0();
output_c(x);
Guest








PostPosted: Wed May 23, 2007 1:05 pm     Reply with quote

Hi Dear Friends..
My code is run but
Sometimes run and sometimes does not run. I thing sometime does not be POR reset. I do not undertand this problem. Please help me for I want to that everytime run this code but how? Best Regards..


Code:


#include <16F505.h>
#use delay(clock=4000000)
#FUSES  INTRC_IO,NOWDT,NOMCLR,PROTECT
//#use rs232(baud=2400, xmit=PIN_B2, INVERT)

#define  Led       PIN_B1

void main()
{
int x
int   sin;
DELAY_MS(500);

      #asm
        clrw                 //clear W
        movlw  0xC6   
        clrwdt              //; clear WDT
        option             
        movlw  0b00000000
        TRIS    6              
        movlw  0b00000000
        TRIS    7
        clrf   0x06
        clrf   0x07      
      #endasm

   while (true)
     {
       set_timer0(0);
       Output_high( Led );
       Delay_ms(1000);
       Output_low( Led );
       Delay_ms(1000);
       sin=get_timer0();
       output_c(X);
      }
.....
.
.
.
.
.
}
Guest








PostPosted: Fri May 25, 2007 2:07 am     Reply with quote

Please help me. I did not solve this problem.
dyeatman



Joined: 06 Sep 2003
Posts: 1923
Location: Norman, OK

View user's profile Send private message

PostPosted: Fri May 25, 2007 5:41 am     Reply with quote

Why did you make all the other changes instead of doing what you were asked by PCM to do?? I would advise you go back to the first code you posted and do exactly what PCM requested then let us know what happened.

Quote:
Do it like this:

Code:
x = get_timer0();
output_c(x);
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