View previous topic :: View next topic |
Author |
Message |
husq
Joined: 08 Dec 2005 Posts: 5
|
SETUP_COUNTERS() with RTCC_INTERNAL?? |
Posted: Thu Dec 08, 2005 3:19 pm |
|
|
Hello,
I have been looking around for a similar project so I wouldn't have to put another one in the fourm but everyones project are different in some way usually just different MCU. But shouldn't some things work exactly on every MCU!?
Well, to get to the point. I have a simple project with some flashing leds and I just can't get i working. I will post it a little bit later. First I would like to ask where can I read about the Setup_counter? I have looked in the Help and in the Manual for the compiler but it makes no sense to me. What does the RTCC_INTERNAL mean? What it's abbreviate for(maby it isn't but usually the hole word makes more sense). And I don't know when to use it and when I don't need it?
In some examples it's used and in some it's not, please someone?
And now to the code.
#include <16LF84A.h>
#use delay(clock=4000000)
#fuses XT, NOWDT, PUT, NOPROTECT
#define DIODE1 PIN_B1
#define DIODE2 PIN_B2
#define ONOFF PIN_B4
void main()
{
//setup_counters (RTCC_INTERNAL, RTCC_DIV_1);
while(TRUE)
{
while(INPUT(ONOFF))
{
output_high(DIODE1);
delay_ms(500);
output_low(DIODE1);
delay_ms(500);
}
output_high(DIODE2);
}
}
The problem is that the DIODE1 dosen't flash. DIODE1 turns on but now flashing and if you change the input the DIODE2 goes on.
I would really appreciate an explanation of this. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Dec 08, 2005 4:07 pm |
|
|
My suggestion is to start with a very simple program, like this,
where you just try to flash the LED:
Code: |
#include <16LF84A.h>
#fuses XT, NOWDT, PUT, NOPROTECT
#use delay(clock=4000000)
#define DIODE1 PIN_B1
void main()
{
while(1)
{
output_high(DIODE1);
delay_ms(500);
output_low(DIODE1);
delay_ms(500);
}
} |
Do you have a series resistor between the LED and the PIC ? |
|
|
husq
Joined: 08 Dec 2005 Posts: 5
|
|
Posted: Fri Dec 09, 2005 1:17 pm |
|
|
Thanks,
Well I tryied the program one more time and it turned out that it wasn't the program, it was my crystal that was kind of messing with me. So I'm working on a little special thing for that. But anyway I would still like to know about the other stuff, anyone?
About when to use the Setup_counter and what the RTCC stands for??
Greatful for any suggestions, and if anyone could recommend some books or papers to read for us newbies? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Dec 09, 2005 1:58 pm |
|
|
RTCC stands for "Real Time Clock Calendar", but that name is obsolete. It's now called Timer0 in all Microchip documents. |
|
|
|