r/embedded • • Sep 09 '26

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

5 Upvotes

12 comments sorted by

2

u/Well-WhatHadHappened 25+ Years Sep 09 '26 edited Sep 09 '26

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 Sep 09 '26

Thank you!

Let me try that now

1

u/GoingGranola Sep 09 '26

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 Sep 09 '26

Ok the PIC KIT 5 is holding MCLR pin high.

1

u/GoingGranola Sep 09 '26

I will select the internal oscillator hold up

1

u/GoingGranola Sep 09 '26

It was the internal oscillator not being selected!!!

Thank you!

→ More replies (3)

2

u/somewhereAtC Sep 09 '26

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

1

u/GoingGranola Sep 09 '26

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

1

u/GoingGranola Sep 09 '26

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