Searching \ for 'PORTA Question!' 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!'.

Truncated match.
PICList Thread
'PORTA Question!'
1997\02\26@183831 by Jean-Francois Joly

flavicon
face
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

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

Thank you!
Jean-Francois
-----------
Jean-Francois & Alain Joly
spam_OUTjolyalTakeThisOuTspamcapitalnet.com

1997\02\26@212140 by Byron A Jeff

face picon face
>
> 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
>
> Would this work?

No.

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

No. For two reasons:

1) The TRISA register is in bank 1 of memory. The RP0 bit in the STATUS
register must be set to 1 before you can access bank 1.

2) To set a port pin as an output, its TRIS bit must be 0.

Correct code:

BSF      PORTA,RA0
BSF      STATUS,RP0
BCF      TRISA,TRISA0
BCF      STATUS,RP0

Hope this helps,

BAJ

1997\02\27@041704 by Peter Grey

picon face
At 06:27 PM 26/02/97 -0500, you wrote:
{Quote hidden}

Please advise what PIC you are using as some setups are different. To have
the port pin as an output you must set the direction bit to zero, ie BCF TRISA,0

Best of luck,


Peter Grey
Neosystems
Australia

1997\02\27@154410 by Philippe TECHER

flavicon
face
Jean-Francois Joly wrote:

>> 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


And Byron A Jeff answer:

>>Correct code:
>>
>>BSF      PORTA,RA0
>>BSF      STATUS,RP0
>>BCF      TRISA,TRISA0
>>BCF      STATUS,RP0

Yes this is the correct code, but there is again another condition to respect:
DON'T USE INTERRUPT DURING THIS PORION OF CODE. If there is an interrup you
will need to keep the bit RP0 exactly in the same state.
Then if you don't have time critical interrupt code, you can use the following
code

BSF      PORTA,RA0
BCF      INTCON,GIE    ; DISABLE ALL INTERRUPT
BSF      STATUS,RP0
BCF      TRISA,TRISA0
BCF      STATUS,RP0
BSF      INTCON,GIE    ; ENABLE GLOBAL INTERRUPT FLAG

Regards,
       Philippe.

1997\02\27@203347 by Bob Fehrenbach

picon face
Philippe TECHER <p.techerspamKILLspamINLANDSYS.COM> wrote:

>>>BSF      PORTA,RA0
>>>BSF      STATUS,RP0
>>>BCF      TRISA,TRISA0
>>>BCF      STATUS,RP0
>
>Yes this is the correct code, but there is again another condition to respect:
>DON'T USE INTERRUPT DURING THIS PORION OF CODE. If there is an interrup you
>will need to keep the bit RP0 exactly in the same state.

Wait a minute Philippe,  don't you save STATUS when you get an
interrupt?  Context saving has been a frequent topic in this forum.
There should be no need to disable interrupts here.

Furthermore, setting up ports is usually done in the initialization
code before interrupts are enabled.  At least that's the way us
old timers do it.  What am I missing here?

--
Bob Fehrenbach    Wauwatosa, WI     .....bfehrenbKILLspamspam.....execpc.com


'PORTA Question!'
1997\03\02@172404 by Alex I. Torres
flavicon
face
  Hi All PICers !

> From: Philippe TECHER <EraseMEp.techerspam_OUTspamTakeThisOuTINLANDSYS.COM>
> Subject:      Re: PORTA Question!

> And Byron A Jeff answer:
>
>>> Correct code:
>>>
>>> BSF      PORTA,RA0
>>> BSF      STATUS,RP0
>>> BCF      TRISA,TRISA0
>>> BCF      STATUS,RP0
b>
b> Yes this is the correct code, but there is again another
b> condition to respect: DON'T USE INTERRUPT DURING THIS PORION
b> OF CODE. If there is an interrup you will need to keep the
b> bit RP0 exactly in the same state. Then if you don't have
b> time critical interrupt code, you can use the following code

Why ?  If You write Your interrupt routine correctly (save and
restore W & Status) it will be work fine.


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

--- GoldED 2.50.A0531+

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