A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
problems with PIC12F675 GPIO - ajellisuk - Oct 6 17:34:11 2009
Hi,
I've just started a project using a PIC12F675.
Just to get started I'm trying to drive all of the port pins high, but I'm having no
success. I'm aware that the ports have multiple functions and need to be set up. I don't
seem to have nay control over any of the pins. I'm using HI Tec PICC lite embedded into
MPLAB 8.1.
My code is:
/* PIC 12F flash.c */
#include "pic12f6x.h"
void main()
{
STATUS = 0b00000000; // Bank 0
CMCON = 0x07;
STATUS = 0b00100000; // Bank 1
WPU = 0b00110111;
ANSEL = 0;
TRISIO = 0x00;
STATUS = 0x00;
GPIO = 0x3F;//(1<<4);
while(1);
}
Could some one please indicate what I have missed.
Kind regards
Andrew
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: problems with PIC12F675 GPIO - Phil Seakins - Oct 8 22:22:26 2009
Erm, it's a long time since I played with HiTech C but as far as I
recall bank selection is transparent to the programmer. In other words
you don't need to fiddle with bank registers because the compiler
takes care of that for you. Your example seems to follow the assembly
language example in the manual which didles with the STATUS register.
I may be totally wrong but I would suggest removing the STATUS
statements and trying again. Take a look at the assembler listing
output that the compiler produces, I _think_ you'll see the automatic
bank selection in action.
Also, it may not hurt to clear GPIO before you setup the port
directions. For various reasons I used to assign a separate variable
as a holder for the GPIO value, then change the variable as required
and copy the variable to the GPIO register each time it needed update.
Sorry, I don't have time right now to dig through my old examples.
Good luck.
On 10/7/09, ajellisuk
wrote:
> Hi,
>
> I've just started a project using a PIC12F675.
>
> Just to get started I'm trying to drive all of the port pins high, but I'm
> having no success. I'm aware that the ports have multiple functions and need
> to be set up. I don't seem to have nay control over any of the pins. I'm
> using HI Tec PICC lite embedded into MPLAB 8.1.
>
> My code is:
>
> /* PIC 12F flash.c */
>
> #include "pic12f6x.h"
>
> void main()
> {
>
> STATUS = 0b00000000; // Bank 0
> CMCON = 0x07;
>
> STATUS = 0b00100000; // Bank 1
> WPU = 0b00110111;
> ANSEL = 0;
> TRISIO = 0x00;
> STATUS = 0x00;
> GPIO = 0x3F;//(1<<4);
>
> while(1);
> }
>
> Could some one please indicate what I have missed.
>
> Kind regards
>
> Andrew
>
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )Re: problems with PIC12F675 GPIO - ajellisuk - Oct 10 13:15:18 2009
Hi Phil,
Thanks for your reply.
I have stumbled across the solution by accident. I needed to add the line:
__CONFIG(INTIO & WDTEN & MCLRDIS & BORDIS & UNPROTECT & PWRTEN);
to my code. Now that I have full control of the port pins I can press on.
Kind regards
Andrew
--- In p...@yahoogroups.com, Phil Seakins
wrote:
>
> Erm, it's a long time since I played with HiTech C but as far as I
> recall bank selection is transparent to the programmer. In other words
> you don't need to fiddle with bank registers because the compiler
> takes care of that for you. Your example seems to follow the assembly
> language example in the manual which didles with the STATUS register.
>
> I may be totally wrong but I would suggest removing the STATUS
> statements and trying again. Take a look at the assembler listing
> output that the compiler produces, I _think_ you'll see the automatic
> bank selection in action.
>
> Also, it may not hurt to clear GPIO before you setup the port
> directions. For various reasons I used to assign a separate variable
> as a holder for the GPIO value, then change the variable as required
> and copy the variable to the GPIO register each time it needed update.
>
> Sorry, I don't have time right now to dig through my old examples.
>
> Good luck.
>
> On 10/7/09, ajellisuk wrote:
> >
> >
> >
> >
> >
> >
> > Hi,
> >
> > I've just started a project using a PIC12F675.
> >
> > Just to get started I'm trying to drive all of the port pins high, but I'm
> > having no success. I'm aware that the ports have multiple functions and need
> > to be set up. I don't seem to have nay control over any of the pins. I'm
> > using HI Tec PICC lite embedded into MPLAB 8.1.
> >
> > My code is:
> >
> > /* PIC 12F flash.c */
> >
> > #include "pic12f6x.h"
> >
> > void main()
> > {
> >
> > STATUS = 0b00000000; // Bank 0
> > CMCON = 0x07;
> >
> > STATUS = 0b00100000; // Bank 1
> > WPU = 0b00110111;
> > ANSEL = 0;
> > TRISIO = 0x00;
> > STATUS = 0x00;
> > GPIO = 0x3F;//(1<<4);
> >
> > while(1);
> > }
> >
> > Could some one please indicate what I have missed.
> >
> > Kind regards
> >
> > Andrew
> >
> >
>
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )