I mus be stupide but..

Begining with pic programing in C

The following prog works on a pic16f84A #include /***** CONFIGURATION *****/ __CONFIG(0x3F61); /***** MAIN PROGRAM *****/ void main() { // Initialisation TRISB = 0b00000000; PORTB = 0b11110000; for (;;) { // turn on LED only if button pressed if ( RA0 == 1 ) PORTB = 0b000011; else PORTB = 0b110000;

} // repeat forever }

But the read RA0 never occurs on a pic16f627 Diplay is allways 0b110000

I am using picc ( lite ) from command line or via a Makefile picc --warn=9 --chip=16f627a less2.c BTW: if I use --strict, it refuse to compile ( to many errors -- FROM the included file /usr/local/hitech/picc/9.8/include/pic16f627.h ) ???

Tested on a Vellman kit K8048 ( here a VM111 as I buy it fully monted )

It gives the same results when using MPlab??

Reply to
Andre
Loading thread data ...

Le 14/04/2012 18:09, Andre a écrit :

BTW: I am using PikDev to prog the chip.

A similar prog in assembler works, so it doesn't seems to be the chip nor the programmer. André Many thanks in advances

Reply to
Andre

Hi Andre,

In order to use a PORTA pin like RA0, you should also setup TRISA. Additionally, the 16f62x has a CMCON register which needs setup, if you want to use RA0..3.

Have a look in the processor's datasheet.

However, I can say nothing about the PICC compiler...I use CC5X.

HTH, Wolfgang

--
From-address is Spam trap
Use: wolfgang (dot) mahringer (at) sbg (dot) at
Reply to
Wolfgang Mahringer

What setup is required to make RA0 an input on a pic16f627? Does the button press actually change the state of RA0? ( put a scope on it, in other words ).

Are you sure your path points you to the right compiler? This sounds a little like you don't have the toolchain set up correctly.

Otherwise...

??? really? I'd find a forum or send their support an email. Is there another #include that pic16f627.h depends on?

Do their #includes include other #includes, or are you expected to do that for them?

Does pic16f627.h have a #if _PIC16F627_H_ at the top ( and the appropriately placed #endif at the bottom) ?

-- Les Cargill

Reply to
Les Cargill

Many thanks.

I don't use MPlab for this as it doesn't support the K8048 programmer. When I use it, I can upload the .hex file into PikDev and then progrem the chip But Mplab use picc. And rememeber tha the same prog work with a pic16f84a ?? I don't have a osciloscope ( Helas ) I am retired and oding this only for fun ;-))) I will be looking at your suggestions asap, my wife's calling ;-)) Andre

Reply to
Andre

RA0 is an analog pin by default. Analog pins cannot be used as digital inputs. You must disable the analog features on the pin (the comparator).

--
John W. Temples, III
Reply to
John Temples

That's was the problem. I configured COMCON and miracle .. Many thanks. André

Reply to
Andre

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.