View previous topic :: View next topic |
Is any of these microcontrollers allowing the use of MCLR and oscillator PIN for input and output? |
PIC12F509 |
|
50% |
[ 1 ] |
PIC12C509A |
|
50% |
[ 1 ] |
PIC12C671 |
|
0% |
[ 0 ] |
|
Total Votes : 2 |
|
Author |
Message |
Jordanel
Joined: 26 Mar 2016 Posts: 17
|
PIC12F509. PIC12C509A, PIC12C671 |
Posted: Tue May 10, 2016 5:06 am |
|
|
Good day! I have disabled the MCLR pin and am using the internal oscillator on these microcontrollers, but that does not give me the OSCI and MCLR pin for input and output functions, I think that at least PIC12F509 should allow me to use the pins for something so what am I doing wrong? Thank you for your help! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Tue May 10, 2016 5:40 am |
|
|
show us your complete code, including the 'fuses' lines.
I KNOW the 509 allows _MCLR to become an input, the other 2 can be In or Out.
I haven't checked the others as I have a 509 in window version here.
Jay |
|
|
Jordanel
Joined: 26 Mar 2016 Posts: 17
|
|
Posted: Tue May 10, 2016 6:01 am |
|
|
Code: |
/* Main.c file generated by New Project wizard
*
* Created: Tue May 10 2016
* Processor: PIC12C671
* Compiler: CCS for PIC
*/
#include <12C671.h>
#fuses NOMCLR, NOPROTECT, NOWDT, INTRC
#use delay(clock= 4 000 000)
int main (void)
{
unsigned int8 ADC = 0;
while (1)
{
output_a(0b111111);
delay_us(10);
ADC ^= input_a();
output_a(0b111111);
if (ADC < 1)
{
output_a(0b111110);
delay_us(10);
}
if (ADC<2)
{
output_a(0b111101);
delay_us(10);
}
else
{
output_a(0b111100);
delay_us(10);
}
}
} |
[img]https://drive.google.com/open?id=0B0mcgD4B6dOqMENOZmM0eHFuMUk[/img] |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Tue May 10, 2016 7:48 am |
|
|
MCLR, is _input only_.
Described in the data sheet.
True on 99% of chips (a few of the very much later chips do allow other operations). Reason is that MCLR, is the programming pin (Vpp). For programming the pin has to be taken 'up' to a relatively high voltage (typically something like 13v), so there cannot be a driver transistor which would become reverse biased when the pin was driven high.
So if you look at the data sheet for the 509:
"Please note that RB3/
GP3 is an input only pin."
Similar notes in the other data sheets.
Also if you look at the pin diagrams, this pin (together with the supply pins), only has a arrow 'inward' on the diagram, while the other pins have arrows both in and out.
A 10 second search here, will find how to turn off the timer, which stops you using the OSC pin. Originally a solution posted by PCM_Programmer using assembler, and then I posted the CCS command that does the same... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Tue May 10, 2016 9:07 am |
|
|
If this
INTRC
is changed to INTRC_IO
it normally allows the OSC pins to be I/O but pointed out above you need to 'patch' the program....
Also this
#use delay(clock= 4 000 000)
while easier to read than 4000000 the compiler may not like
you could use
clock=4M
which is the same as 4000000
and
Calling a variable ADC is not really 'good' coding as most will assume you're talking about an Analog Digital Converter not just simple digital inputs.
Jay |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue May 10, 2016 1:29 pm |
|
|
BTW: re your 'poll' ??
you don't need a POLL or a guess.... or an opinion-
you just need to read the data sheet to KNOW for sure |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Tue May 10, 2016 1:39 pm |
|
|
temtronic wrote: | If this
INTRC
is changed to INTRC_IO
it normally allows the OSC pins to be I/O but pointed out above you need to 'patch' the program....
Also this
#use delay(clock= 4 000 000)
while easier to read than 4000000 the compiler may not like
you could use
clock=4M
which is the same as 4000000
and
Calling a variable ADC is not really 'good' coding as most will assume you're talking about an Analog Digital Converter not just simple digital inputs.
Jay |
That will handle the OSC pin, but he will probably have trouble with the timer1 oscillator input, which defaults to enabled. Hence this needs to be disabled as well. There have been threads about this in the past. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Tue May 10, 2016 2:50 pm |
|
|
too many options on too few pins ! Nice 'glue logic' PIC though when it was new...
Jay |
|
|
Jordanel
Joined: 26 Mar 2016 Posts: 17
|
|
Posted: Sun Jun 19, 2016 5:41 pm |
|
|
temtronic wrote: | If this
INTRC
is changed to INTRC_IO
it normally allows the OSC pins to be I/O but pointed out above you need to 'patch' the program....
Also this
#use delay(clock= 4 000 000)
while easier to read than 4000000 the compiler may not like
you could use
clock=4M
which is the same as 4000000
and
Calling a variable ADC is not really 'good' coding as most will assume you're talking about an Analog Digital Converter not just simple digital inputs.
Jay |
Thank you all for the help. It is and analog-to-digital converter, but the ADC is external. The idea is to be able to use PIC12 to index 63 devices, having 6 pins. If I make it 3 pins it becomes 8 devices and thats not enough.
How exactly do I need to patch the program in order to make it at least 5 pins? I think that this is enough INTRC_IO?
How can I fix this?
"
That will handle the OSC pin, but he will probably have trouble with the timer1 oscillator input, which defaults to enabled. Hence this needs to be disabled as well. There have been threads about this in the past."
This is the patching that I should I guess, but how exactly?
On the simulation software everything is working fine. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Mon Jun 20, 2016 5:12 am |
|
|
This ...
.....need 6 I/O pins.....well, 5 might do...
is a classic example of
'use a bigger PIC' !
Cost for a 'project' is NOT only the hardware (PIC, PCB and parts..) and software (code cutting..) but also 'head scratching' development time. I'd hate to see the amount of hours or days spent on trying to use a PIC12 for this project. ANY PIC18, even the PIC16C84, would do the job, easily in a morning and 2 or 3 coffees! Yes, it cost a few pennies more but save hundreds of dollars in true R&D costs (your labour).
Also as we all KNOW... projects 'grow', clients 'need' another feature, so you have to find another I/O pin, more RAM,etc.
Now the 509 can be configured for 5 outputs and a search of this forum will show answers to how, but getting back to the original post. You seem to be using the PIC12 as a 'digital switch', free running to select one of 63 ADC devices? If so, you'd be better off using the PIC that does read the ADC devices as the 'switch' as for one thing, the 'master' PIC has NO way of knowing which of the 63 ADCs it's reading !!
Jay |
|
|
Jordanel
Joined: 26 Mar 2016 Posts: 17
|
This is not for reducing costs! |
Posted: Tue Jun 21, 2016 8:56 am |
|
|
This is not for reducing costs, this is for educational purposes! I decided to start learning with PIC12, not that PIC16 doesnt have 39 I/O pins. But I want to learn the basics with PIC10 and PIC12 first and then start using more complecated microcontrollers. Its the best option according to me! |
|
|
RF_Developer
Joined: 07 Feb 2011 Posts: 839
|
|
Posted: Tue Jun 21, 2016 9:06 am |
|
|
I'm not at all sure that's a sensible approach. The 10s and 12s have restrictions and complications that the 16s and 18s don't have. The 16s are old and largely legacy products. They are hardly the best, nor the simplest PICs to start to learn. Instead, I'd just skip over the 10/12/16s and start on a mid-range 18. No USB or CAN, just a pretty basic but decent spec 18. No nasty restrictions, a decent range of peripherals to play with. Loads of IO pins. Decent amount of memory. No legacy related restrictions such as limited, paged memory space. More modern, and therefore less quirky and more representative processor core. You can easily migrate to doing actual work with them, as opposed to playing. All in all a lot going for them as a basic, learning platform PIC. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Jun 21, 2016 4:40 pm |
|
|
i'm with RF developer 100% .
i started with PIC16 but was very glad when i migrated to PIC18
the tiny chips are a real PITA and i would only use one if i have to.
don't start your education with impaired parts. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Tue Jun 21, 2016 6:06 pm |
|
|
I'm in the same boat, finally got a PIC18 and never looked back. I tend to 'overPIC' my projects, using the PIC18F46K22 as my 'GoTo' PIC. I needed a PIC with two hardware UARTs several years ago and that ONE PIC has never let me down. While I still have lots of 16 series here, collecting dust, having a 'one PIC does all is a LOT easier! I have years worth of 'library' functions that I KNOW do work, I don't 'upgrade' to newer PICs that might be better as my time is money. I can't afford to waste 3 or 4 days trying to debug why code doesn't work. Is it the new PIC, a compiler bug, a misprint in the datasheet or a bad PCB?
Simple example.. most neat external peripherals are 3 volts but LCD modules are 5 volts. OK 3 volt ones are available but $$$ ! By using a spare PWM pin on the 46k22, 2 caps and 2 diodes I can use the cheaper 5 volt LCD modules on 3 volt PIC projects. Just a couple lines of code and presto a 4by20 LCD on a 3volt PIC.
Jay |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Jun 21, 2016 7:45 pm |
|
|
18F26k22 dc-64 mhz 1024 eeprom 3896sram 64k progmem $2.21/100
or
16f76 dc-20mhz no eeprom 368sram 8k progmem $ 4.10/100
Excellent CCS support for both chips - but which one might still be in production in 10 years?
i have a product that uses a 16F616 - i'm not against the 16F line.
but the 10f 12f parts are really for special tiny stuff.
if you are learning basic skill don't hamper yourself |
|
|
|