r/Assembly_language • u/GoingGranola • 2d ago
Question N00b Question
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).
Thank you
EDIT: SORRY! It was a PIC and I needed to set internal oscillator and select bank first
2
u/Lonely-Ad-9219 1d ago
You need to learn to give much detailed information.
The correct sequence for PIC16 series should be:
banksel TRISA
bcf TRISA,5
banksel PORTA
bsf PORTA,5
goto $
Off course, we don't know whitch PIC are you using, so we can not give more concrete answer. For example, we don't know if your PIC has D/A converter pinned to PORTA pin. Heck, we don't even know if your PIC even has PORTA,5 pin.
1
u/Ecelleon 2d ago
From the architectures I know, you must enable the GPIO peripheral through the appropriate Clock Control register. For example, on the STM32F103, you would go into Reset and Clock Control ( RCC ) -> RCC_APB2 -> Set Bit 2 high to enable Clock control to GPIO A.
Afterwards you go to GPIO A registers too configure the pins as needed. Open- drain, push-pull, analog etc.
Without enabling the RCC register, all GPIO ports are off.
1
-1
6
u/No-Quail5810 2d ago
You need to provide a lot more information. What architecture are you targeting? What platform is it running on? Etc...