Searching \ for '[PIC] PICC problem' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'PICC problem'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] PICC problem'
2008\04\01@042418 by Ivan Petrushev

picon face
Hello,
I have experience with sdcc (small device c compiler), but I want to
move to Hi-Tech PICC compiler. The problem is that I'm testing a very
simple code and it doesn't work:
#include <pic.h>

void main(void){
       unsigned char count = 0;
       TRISA = 0xff;
       while(1){
               count++;
               PORTA=count;
       }
}
I'm compiling this in MPlab and it is okay, but when I go to watch and
simulate the program, I see only the 'coun't variable change. PORTA
doesn't change. I'm compiling this for PIC16F88.
Any ideas what I am doing wrong? :)

Regards, Ivan.

2008\04\01@044026 by Rikard Bosnjakovic

picon face
On 01/04/2008, Ivan Petrushev <spam_OUTivanatoraTakeThisOuTspamgmail.com> wrote:
> Hello,
>  I have experience with sdcc (small device c compiler), but I want to
>  move to Hi-Tech PICC compiler. The problem is that I'm testing a very
>  simple code and it doesn't work:
>  #include <pic.h>
>
>  void main(void){
>         unsigned char count = 0;
>         TRISA = 0xff;
>         while(1){
>                 count++;
>                 PORTA=count;
>         }
>  }

Is that test-code for PICC? If so, replace #include <pic.h> with
#include <htc.h> and #include <pic16f87.h> and try again.

Also, PICC uses unsigned chars per default (unless you uncheck the box
in project options), it will be enough for you to declare "char count
= 0".


--
- Rikard - http://bos.hack.org/cv/

2008\04\01@050610 by Ivan Petrushev

picon face
I found it, I had to set ANSEL to 0 :)

On Tue, Apr 1, 2008 at 11:40 AM, Rikard Bosnjakovic
<.....rikard.bosnjakovicKILLspamspam@spam@gmail.com> wrote:
{Quote hidden}

>  --

2008\04\01@051801 by Rikard Bosnjakovic

picon face
On 01/04/2008, Ivan Petrushev <.....ivanatoraKILLspamspam.....gmail.com> wrote:

> I found it, I had to set ANSEL to 0 :)

That's generally a good idea, yes :-)


--
- Rikard - http://bos.hack.org/cv/

2008\04\01@053801 by Brent Brown

picon face
On 1 Apr 2008 at 11:23, Ivan Petrushev wrote:

> Hello,
> I have experience with sdcc (small device c compiler), but I want to
> move to Hi-Tech PICC compiler. The problem is that I'm testing a very
> simple code and it doesn't work:
> #include <pic.h>
>
> void main(void){
>        unsigned char count = 0;
>        TRISA = 0xff;
>        while(1){
>                count++;
>                PORTA=count;
>        }
> }
> I'm compiling this in MPlab and it is okay, but when I go to watch and
> simulate the program, I see only the 'coun't variable change. PORTA
> doesn't change. I'm compiling this for PIC16F88.
> Any ideas what I am doing wrong? :)

Change to TRISA = 0x00 to make each port line an output instead of an input.

:-)

--
Brent Brown, Electronic Design Solutions
16 English Street, St Andrews,
Hamilton 3200, New Zealand
Ph: +64 7 849 0069
Fax: +64 7 849 0071
Cell: +64 27 433 4069
eMail:  EraseMEbrent.brownspam_OUTspamTakeThisOuTclear.net.nz


2008\04\01@110515 by Ivan Petrushev

picon face
>  Change to TRISA = 0x00 to make each port line an output instead of an input.
>
>  :-)
Is there a difference between TRISA = 0, and TRISA = 0x00?
I see you can specify hex numbers with 0xNUM, decimal with NUM and
binary with 0bNUM.
Is there a way to specify octal numbers? :)
I don't need it now, and I don't know if I will ever need that, but it
is always good to be informed.

Regards,
Ivan.

2008\04\01@111733 by Peter Todd

flavicon
face
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, Apr 01, 2008 at 06:04:38PM +0300, Ivan Petrushev wrote:
> >  Change to TRISA = 0x00 to make each port line an output instead of an input.
> >
> >  :-)
> Is there a difference between TRISA = 0, and TRISA = 0x00?

None what so ever, base-10 0 is equal to base 16 0.

> I see you can specify hex numbers with 0xNUM, decimal with NUM and
> binary with 0bNUM.
> Is there a way to specify octal numbers? :)

Sure is, though it's a bit odd, simply write the number with a 0 as the
first digit, 0777 = 511 = 0x1ff

FWIW the Python language thinks that syntax is so likely to cause new
users problems they're switching to 0o777 (where the x in hex is
replaced with an o) for Python 3.0 They're also adding direct support to
specify binary numbers with 0b1010

- --
peter[:-1]@petertodd.org http://petertodd.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFH8lFA3bMhDbI9xWQRAiiRAJ9jA6moH2fq2yK2Un+EmlxmARMJ8wCghVnM
Hz6LjQtioBJhjlizPGlcpD4=
=Q9Li
-----END PGP SIGNATURE-----

2008\04\01@112337 by William Couture

face picon face
On Tue, Apr 1, 2008 at 11:04 AM, Ivan Petrushev <ivanatoraspamspam_OUTgmail.com> wrote:

> >  Change to TRISA = 0x00 to make each port line an output instead of an input.
>  >
>  >  :-)
>  Is there a difference between TRISA = 0, and TRISA = 0x00?

No.

>  I see you can specify hex numbers with 0xNUM, decimal with NUM and
>  binary with 0bNUM.
>  Is there a way to specify octal numbers? :)

Yes.  A leading 0 means the number is octal.  This is part of standard C.

For example:
  0x10 == 16 (decimal)
  010  ==   8 (decimal)
    10 == 10 (decimal)

Bill

--
Psst... Hey, you... Buddy... Want a kitten? straycatblues.petfinder.org

2008\04\01@113346 by Spehro Pefhany

picon face
Quoting Ivan Petrushev <@spam@ivanatoraKILLspamspamgmail.com>:

>>  Change to TRISA = 0x00 to make each port line an output instead of  
>>  an input.
>>
>>  :-)
> Is there a difference between TRISA = 0, and TRISA = 0x00?
> I see you can specify hex numbers with 0xNUM, decimal with NUM and
> binary with 0bNUM.
> Is there a way to specify octal numbers? :)
> I don't need it now, and I don't know if I will ever need that, but it
> is always good to be informed.

Leading '0' (zero) gives you octal. Eg. 010 is 0x8 or 8

There is no built-in way of doing base2 in ANSI C, unfortunately, so
many of us avoid using 0bxxxx in the interests of portability. With a
bit of practice, hex isn't too bad.

Best regards,
Spehro Pefhany
--
"it's the network..."                          "The Journey is the reward"
KILLspams...KILLspamspaminterlog.com             Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog  Info for designers:  http://www.speff.com

2008\04\01@113658 by Dario Greggio

face picon face
Ivan Petrushev wrote:

> Is there a difference between TRISA = 0, and TRISA = 0x00?

not for 0 :)

--
Ciao, Dario

2008\04\01@115643 by Spehro Pefhany

picon face
Quoting Dario Greggio <RemoveMEadpm.toTakeThisOuTspaminwind.it>:

> Ivan Petrushev wrote:
>
>> Is there a difference between TRISA = 0, and TRISA = 0x00?
>
> not for 0 :)

Even for relatively large values of 0, up to 8 or 9, it seems to be okay.

;-)

> --
> Ciao, Dario
> -

2008\04\01@115825 by Ivan Petrushev

picon face
Okay, people, thanks for the answers! I think I can do math :P
It is easier to me to represent binary numbers as hex, and it is lots
easier to read.

I think there are more interesting threads here to waste time on ;)
So lets consider this thread as closed, unless someone has to add something new

Regards, Ivan.

On Tue, Apr 1, 2008 at 6:33 PM, Spehro Pefhany <spamBeGonespeffspamBeGonespaminterlog.com> wrote:
{Quote hidden}

>  --

More... (looser matching)
- Last day of these posts
- In 2008 , 2009 only
- Today
- New search...