View previous topic :: View next topic |
Author |
Message |
hoa35ktxd
Joined: 23 Nov 2014 Posts: 27 Location: Vietnam
|
Is there any special for PIC12F617? |
Posted: Thu Mar 03, 2016 9:25 am |
|
|
I tested with a small program but did not see any active even I have changed some others new IC.
Suppose that I bought fake one?
My code:
Code: |
#include <12F617.h>
#FUSES NOMCLR
#FUSES PROTECT
#use delay(internal=4000000)
void main()
{
while(TRUE)
{
Output_high(PIN_A2);
delay_ms(150);
Output_low(PIN_A2);
delay_ms(350);
Output_high(PIN_A3);
delay_ms(150);
Output_low(PIN_A3);
delay_ms(350);
}
}
|
I use PICKIT3.
Thanks. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Thu Mar 03, 2016 9:36 am |
|
|
Which pin are you testing?. A3, is _input only_, and is the MCLR line unless you program it otherwise. Chip won't run unless this is pulled high, or you add 'NOMCLR' to the fuses. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Thu Mar 03, 2016 10:34 am |
|
|
also
you should never #fuse PROTECT until the FINAL product is 100% tested and 'market ready' !
Jay |
|
|
hoa35ktxd
Joined: 23 Nov 2014 Posts: 27 Location: Vietnam
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Fri Mar 04, 2016 2:23 am |
|
|
As posted, it won't, unless you have a pullup on pin A3. |
|
|
hoa35ktxd
Joined: 23 Nov 2014 Posts: 27 Location: Vietnam
|
|
Posted: Fri Mar 04, 2016 3:26 am |
|
|
Ttelmah wrote: | As posted, it won't, unless you have a pullup on pin A3. |
Thank you.
I just wonder about the software only.
On the hardware side, I already know how to connect. I have done with many other IC then (for example 12F683).
Pull-up resistor on pin A3: I changed it and combined with the change "NOMCLR" in the code. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Fri Mar 04, 2016 4:34 am |
|
|
You have things backwards.
With 'NOMCLR', you don't need the resistor.
Without it you do.
Then you need to ensure everything else on the pins you want to use is turned 'off'. For instance, GP4, will often default to being the CLKOUT pin. So you need the INTRC_IO fuse to tell the compiler to turn this off. Also a lot of chips wake up with the watchdog enabled. It is never going to run if this is the case, so the NOWDT fuse. Also chips with the comparator often need this turned off if you are going to use the comparator pins. so a setup_comparator line to do this. Then just test on A5. If this starts working, then the chip is running, so it then becomes a matter of just testing the other pins. If they don't work, assume you have a compiler version that does not disable things like the analog inputs by default, so manually turn these off. |
|
|
hoa35ktxd
Joined: 23 Nov 2014 Posts: 27 Location: Vietnam
|
|
Posted: Fri Mar 04, 2016 8:39 am |
|
|
Thanks for Ttelmah enthusiasm.
I need you to help me a standard configuration (software and hardware) to be able to control any PIN.
You experimental field with 12F617 yet?
I need that. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Fri Mar 04, 2016 9:00 am |
|
|
Just tried a chip, and this merrily sits toggling A0:
(with 5.053)
Code: |
#include <12F617.h>
#device ADC=10
#fuses NOWDT, INTRC_IO, NOMCLR
#use delay(internal=4000000)
void main()
{
setup_comparator(NC_NC);
setup_adc(ADC_OFF);
setup_adc_ports(NO_ANALOGS);
while(TRUE)
{
output_toggle(PIN_A0);
delay_ms(100);
}
}
|
|
|
|
hoa35ktxd
Joined: 23 Nov 2014 Posts: 27 Location: Vietnam
|
|
Posted: Fri Mar 04, 2016 9:57 am |
|
|
Ttelmah wrote: | Just tried a chip, and this merrily sits toggling A0:
(with 5.053)
Code: |
#include <12F617.h>
#device ADC=10
#fuses NOWDT, INTRC_IO, NOMCLR
#use delay(internal=4000000)
void main()
{
setup_comparator(NC_NC);
setup_adc(ADC_OFF);
setup_adc_ports(NO_ANALOGS);
while(TRUE)
{
output_toggle(PIN_A0);
delay_ms(100);
}
}
|
|
Thank Ttelmah very much.
The key problem is in "INTRC_IO"
After adding: "#fuses INTRC_IO" everything was operating normally.
#fuses INTRC_IO: What does it mean? In ccs help did no such thing. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19513
|
|
Posted: Fri Mar 04, 2016 10:16 am |
|
|
As I said a couple of posts ago:
"So you need the INTRC_IO fuse to tell the compiler to turn this off".
Without this A4 is left with OSC/4 as an output on it. Shouldn't affect A0 though. Are you sure it is not the NOWDT?. As I pointed out early on, the code won't run if the watchdog is enabled. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Fri Mar 04, 2016 10:30 am |
|
|
re:
#fuses INTRC_IO: What does it mean?
It means to program the PIC to use the interal oscillator AND allow the I/O pins normally used with xtal/caps to be used for Input or Output. originally PICs needed 2 I/O pins for the xtal/caps, newer one can use an internal osicillator so those 2 pins are 'free' to be used for other functions. But... not all PICs allow for both pins to used AND some can only be an input or an output so it is very,very important to read the PIC's datasheet that you're using.
You need to take the read the Microchip datasheet for the PIC that you're using. FUSES are a 'low level' function of the PIC, NOT a CCS C code 'feature'. That's probably why it's not in the CCS Help section.
I understand English is difficult to understand ! It's my native language and after 6 decades it can be a problem for me !! I also know reading 400-500 pages of technical stuff is hard, but just take a section at a time, or just one peripheral. It gets better the more you read and all PICs are very similar.
Jay |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Fri Mar 04, 2016 10:36 am |
|
|
In the data sheet it is found in section 4.1 and section 4.4 _________________ Google and Forum Search are some of your best tools!!!! |
|
|
hoa35ktxd
Joined: 23 Nov 2014 Posts: 27 Location: Vietnam
|
|
Posted: Fri Mar 04, 2016 10:59 am |
|
|
Would like to thank everyone for your interest in my problem.
Please confess: I am not a trained electronics and do not know much about English. I love science and electronics enthusiasts, and only self-learning principle.
What I exchanged here is because of google translate.
Sincerely. |
|
|
|