View previous topic :: View next topic |
Author |
Message |
Budius
Joined: 01 Sep 2009 Posts: 8 Location: England
|
[help] Problems with 12F508 and 12F509 acting weird |
Posted: Mon Aug 09, 2010 4:07 am |
|
|
hi guys,
I've been debugging this again and again and it's odd cause it acts differently each time...
I'm using PCWH to program and Mach-x through CCSLOAD to flash the chips.
Mach-x is running at 4.75V.
I'm testing this just applying 5volts to the pins and testing back with a LED.
Code: |
#include <12F509.h>
#fuses INTRC, NOWDT, NOPROTECT, NOMCLR
#use delay(clock=4000000)
#define set_options(value) {#ASM \
MOVLW value \
OPTION \
#ENDASM}
// Inputs
#define in5 !INPUT(PIN_B5)
#define in4 !INPUT(PIN_B4)
#define in3 !INPUT(PIN_B3)
//==================================
void main()
{
set_tris_b (0x38); // PINs_B0-2 output // PINs_B3-5 input
set_options(0xC0); // Allow use of GP2 for i/o
// All off
output_low(PIN_B0);
output_low(PIN_B1);
output_low(PIN_B2);
while(TRUE)
{
/*
output_high(PIN_B0);
output_high(PIN_B1);
output_high(PIN_B2);
delay_ms(500);
output_low(PIN_B0);
output_low(PIN_B1);
output_low(PIN_B2);
delay_ms(500);*/
if(in5) output_high(PIN_B0);
else output_low(PIN_B0);
if(in4) output_high(PIN_B1);
else output_low(PIN_B1);
if(in3) output_high(PIN_B2);
else output_low(PIN_B2);
}
}
|
With the above code the chip turns B0 and B2 together if I apply voltage to in5 and does nothing on the other inputs.
If I swap the code to the blinking code that is commented it does nothing at all.
We have running here a much much complex 18F8722 with no problems. But this little simple chip is been a HUGE headache.
Any suggestions is greatly appreciate.
Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Aug 09, 2010 11:13 am |
|
|
Quote: |
#include <12F509.h>
#fuses INTRC, NOWDT, NOPROTECT, NOMCLR
#use delay(clock=4000000)
// Inputs
#define in5 !INPUT(PIN_B5)
#define in4 !INPUT(PIN_B4)
#define in3 !INPUT(PIN_B3)
|
Look at the pin features in the 12F509 data sheet, and at the oscillator
options. Look at the possible #fuse settings for the internal oscillator
in the 12F509.h file. Then you will see what is wrong. |
|
|
Rijiru
Joined: 07 Sep 2010 Posts: 3
|
|
Posted: Tue Sep 07, 2010 6:38 pm |
|
|
Hi, I've a trouble with PIC 12F509, when I program the chip, GP2(PIN_B2) no works. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Rijiru
Joined: 07 Sep 2010 Posts: 3
|
|
Posted: Wed Sep 08, 2010 2:32 pm |
|
|
Hi, PCM programmer thank you for your help, GP2 works, with a macro added.
Greetings |
|
|
|