View previous topic :: View next topic |
Author |
Message |
ikague Guest
|
Help for rf12F675H |
Posted: Tue Oct 12, 2004 11:47 pm |
|
|
Hi all
I have wroten this Code for the rf12F675H . But nothing happens.
Code: |
#include "12f675.h"
#case
#use delay(clock=4000000)
#fuses hs,noprotect,nobrownout,put,nowdt
void main()
{
while(1)
{
output_high(PIN_A0);
output_high(PIN_A1);
output_high(PIN_A2);
output_high(PIN_A3);
output_high(PIN_A4);
output_high(PIN_A5);
delay_ms(500);
output_low(PIN_A0);
output_low(PIN_A1);
output_low(PIN_A2);
output_low(PIN_A3);
output_low(PIN_A4);
output_low(PIN_A5);
delay_ms(500);
}
}
|
Do someone see an Error ???
Ikague |
|
|
Guest
|
|
Posted: Wed Oct 13, 2004 12:57 am |
|
|
Hi
I forgot. I use the internal oscillator. |
|
|
kypec
Joined: 20 Sep 2003 Posts: 54
|
|
Posted: Wed Oct 13, 2004 1:29 am |
|
|
I'm not sure whether the compiler configures
all the port pins which share the A/D feature
automatically as DIGITAL I/O or not.
I wouldn't rely on it and better have done it
myself:
Code: | setup_adc_ports(NO_ANALOGS) |
Same applies to Analog comparators:
Code: | setup_comparators(NC_NC_NC_NC) |
For further details please look in your
PICC\Devices\12F675.h header file |
|
|
dvsoft
Joined: 28 Nov 2003 Posts: 46
|
|
Posted: Wed Oct 13, 2004 2:08 am |
|
|
bonjour,
Code: |
#include <12F675H.h>
#device adc=8
#use delay(clock=20000000)
#fuses NOWDT,INTRC, NOCPD, NOPROTECT, MCLR, NOPUT, BROWNOUT
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
|
try this code setup
Alain |
|
|
languer
Joined: 09 Jan 2004 Posts: 144 Location: USA
|
|
Posted: Wed Oct 13, 2004 1:21 pm |
|
|
Ikague,
You are currently using this:
Quote: | #include "12f675.h"
#case
#use delay(clock=4000000)
#fuses hs,noprotect,nobrownout,put,nowdt |
You want to change it to this (so you use the internal oscillator):
Code: | #include "12f675.h"
#device ADC=10
#case
#use delay(clock=4000000)
#fuses intrc_io,noprotect,nobrownout,put,nowdt,nocpd,nomclr |
The #fuses command is the source of your problems. You did not define the intrc_io (enables internal oscillator, and IO function on GP4 and GP5), you used hs instead (for external high-speed oscillator). You also did not define nomclr to free GP3 (for input only)
Disable comparators and ADC function (as suggested previously):
Code: | setup_comparator( NC_NC_NC_NC ); // disable comparators
setup_adc_ports( NO_ANALOGS ); // disable analog inputs
setup_adc( ADC_OFF ); // disable A2D
|
And eliminate:
Quote: | output_high(PIN_A3); | and
Quote: | output_low(PIN_A3); | since you can only use this pin as an input.
Hope this helps. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Oct 13, 2004 1:37 pm |
|
|
Code: | setup_comparator( NC_NC_NC_NC ); // disable comparators
setup_adc_ports( NO_ANALOGS ); // disable analog inputs
setup_adc( ADC_OFF ); // disable A2D |
I think you are using PCM vs. 3.099. If so, the functions shown
above do not work properly for the 12F675.
To fix the problem, you need to directly set the register values
for the comparators and the ADC. Look at the highlighted lines
in following link. You need to add those six lines of code to your
program, in the same positions as shown in this link.
http://www.ccsinfo.com/forum/viewtopic.php?t=2808&highlight=cmcon+adcon0+ansel |
|
|
ikague Guest
|
It works!!!!! |
Posted: Wed Oct 13, 2004 9:48 pm |
|
|
Thanks All. It works now !!!!!!! |
|
|
|