View previous topic :: View next topic |
Author |
Message |
Guest
|
16F505 Problem |
Posted: Sat May 05, 2007 6:15 am |
|
|
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
|
|
Posted: Sun May 06, 2007 4:19 pm |
|
|
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
|
|
Posted: Wed May 23, 2007 1:05 pm |
|
|
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
|
|
Posted: Fri May 25, 2007 2:07 am |
|
|
Please help me. I did not solve this problem. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Fri May 25, 2007 5:41 am |
|
|
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); |
|
|
|
|
|