Searching \ for 'PORTA Question!yal@CAPITALNET' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/ios.htm?key=port
Search entire site for: 'PORTA Question!yal@CAPITALNET'.

Truncated match.
PICList Thread
'PORTA Question!yal@CAPITALNET'
1997\03\01@172550 by Alex I. Torres

flavicon
face
  Hi All PICers !

> From: Jean-Francois Joly <spam_OUTjolyalTakeThisOuTspamCAPITALNET.COM>
> Subject:      PORTA Question!

> Hello everyone!
>
> I would like to make a little program that sends a high on
> the RA0 pin to light up a LED. I think it should be simple
> enought, but because this is my first attempt in programming
> a PIC, Im not to sure...
>
> This is the main part of the program. If something is wrong
> or missing, please tell me!
>
>         BSF     PORTA, RA0      ; Want to put 1 on RA0 pin
>         BSF     TRISA, TRISA0   ; Output a high on RA0 pin

          ^^^  bcf, at first.

What about ROM PAGE selecting ?  PORTA is on the 0-page, but
TRISA - on 1st once.
You must write:
      bcf porta,ra0
      bsf status,RP0
      bsf trisa,0
      bcf status,RP0.

More better - to use macros and defines, for example:
;
#define  A0_ON    bsf porta,0
#define  A0_OFF   bcf porta,0
#define  A0_INP   bsf trisa & 0x7f,0
#define  A0_OUT   bcf trisa & 0x7f,0
;
PAGESET    macro pagenum
               if pagenum == 1
                 bsf status,RP0
               else
                 bcf status,RP0
               endif
          endm
;
;After that your program looks like :
;
         A0_ON
         PAGESET 1
         A0_OUT
         PAGESET 0
;

> Would this work?

See before :-)

>  Does it send the signal to the pin at the
> same moment that I set in the TRISA register pin RA0 as
> output?


Yes, of course.

  Best Wishes, Alex Torres.
  Kharkov, Ukraine, exUSSR.
  E-Mail To : .....altorKILLspamspam@spam@cook.kharkov.ua   via InterNet
              or 2:461/28             via FidoNet

--- GoldED 2.50.A0531+

1997\03\02@094117 by Jean-Francois Joly

flavicon
face
Hello!

>       bcf porta,ra0
>       bsf status,RP0  ; Change bank 1
>       bsf trisa,0
>       bcf status,RP0  ; Change back to bank 0

Why do you change back to bank 0 after?

> >  Does it send the signal to the pin at the
> > same moment that I set in the TRISA register pin RA0 as
> > output?
>
>
>Yes, of course.

But what if I set the direction first with the TRIS register like Ed Tood
told me in his last message and then I set the output latch?

TTYL!
Jean
---------------
Jean-Francois & Alain Joly
jolyalspamKILLspamcapitalnet.com

1997\03\02@132639 by Byron A Jeff

face picon face
>
> Hello!
>
> >       bcf porta,ra0
> >       bsf status,RP0  ; Change bank 1
> >       bsf trisa,0
> >       bcf status,RP0  ; Change back to bank 0
>
> Why do you change back to bank 0 after?

Because you want to make sure that future accesses to the ports and
registers are in bank 0. It's good programming practice.

{Quote hidden}

Then whatever value is in the output latch when you set the TRIS register
will appear on the pin briefly until it's changed. By setting the latch
first, there's no possibility of a glitch.

BAJ

1997\03\04@105641 by Jean-Francois Joly

flavicon
face
Hi!

>> >       bcf porta,ra0
>> >       bsf status,RP0  ; Change bank 1
>> >       bsf trisa,0
>> >       bcf status,RP0  ; Change back to bank 0
>>
>> Why do you change back to bank 0 after?
>
>Because you want to make sure that future accesses to the ports and
>registers are in bank 0. It's good programming practice.

Oh ok... and when you execute the BCF PORTA,RA0 instruction on the first
line, your supposing that we are already in bank 0  'cause PORTA is in bank 0?


>Then whatever value is in the output latch when you set the TRIS register
>will appear on the pin briefly until it's changed. By setting the latch
>first, there's no possibility of a glitch.

Cool! Well, thanks a lot for your help and all the people who helped me with
that PORTA Question!

Jean-Francois
---------------
Jean-Francois & Alain Joly
.....jolyalKILLspamspam.....capitalnet.com

1997\03\04@110633 by Byron A Jeff

face picon face
>
> Hi!
>
> >> >       bcf porta,ra0
> >> >       bsf status,RP0  ; Change bank 1
> >> >       bsf trisa,0
> >> >       bcf status,RP0  ; Change back to bank 0
> >>
> >> Why do you change back to bank 0 after?
> >
> >Because you want to make sure that future accesses to the ports and
> >registers are in bank 0. It's good programming practice.
>
> Oh ok... and when you execute the BCF PORTA,RA0 instruction on the first
> line, your supposing that we are already in bank 0  'cause PORTA is in bank 0?

Precisely.

>
>
> >Then whatever value is in the output latch when you set the TRIS register
> >will appear on the pin briefly until it's changed. By setting the latch
> >first, there's no possibility of a glitch.
>
> Cool! Well, thanks a lot for your help and all the people who helped me with
> that PORTA Question!

You're welcome. Hope to see more of your questions on the list.

BAJ

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