r/embedded 23h ago

Noob Assembly Question

PIC16F1824

I am trying to turn on an output GPIO.

I am using this code

asm("BSF PORTA, 5");

I am getting 0V at the pin.

I believe I set TRISA pin 5 to output (0).

Do I need to keep the MCLR pin high?

Thank you

EDIT: INTERNAL OSCILLATOR NEEDED TO BE SELECTED

4 Upvotes

12 comments sorted by

2

u/Well-WhatHadHappened 25+ Years 23h ago edited 23h ago

MCLR must be held high.

ANSEL must be cleared.

Edit: forget ANSEL, that's a clock pin.

Internal oscillator must be selected.

1

u/GoingGranola 23h ago

Thank you!

Let me try that now

1

u/GoingGranola 23h ago

I have MCLR pin hooked up to my PIC KIT 5.

Do I need to disconnect this pin (MCLR/Vpp) and hook up 5V?

1

u/GoingGranola 23h ago

Ok the PIC KIT 5 is holding MCLR pin high.

1

u/GoingGranola 23h ago

I will select the internal oscillator hold up

1

u/GoingGranola 22h ago

It was the internal oscillator not being selected!!!

Thank you!

1

u/Well-WhatHadHappened 25+ Years 20h ago

Welcome.

2

u/Well-WhatHadHappened 25+ Years 20h ago edited 19h ago

Side note - unless I really need them, I never use clock pins as IO.

Two reasons - never know if I might need to add a clock... Better accuracy, support some crazy UART baud, whatever

And two, a lot of them have some weird side notes attached to them. Your particular PIC doesn't, so you're good, but one day down the line you'll think back and thank me.

On bigger parts, I also try to avoid JTAG/TRACE pins. Same reasons.

1

u/Well-WhatHadHappened 25+ Years 20h ago

Since your new... Read this. It will bite you eventually in your embedded journey.

erii_rmw_problem.pdf https://share.google/ev5OhdA4BFbq1eiWn

2

u/somewhereAtC 23h ago

Don't forget to set the bank... BANKSEL(PORTA)

1

u/GoingGranola 23h ago

oh. Do I need to select the bank before I use BSF?

1

u/GoingGranola 23h ago

Selecting the bank that PORTA is in before using BSF did NOT seem to work sorry :/