Please note: I am a beginner. I started to learn AVR ASM on my own about 1/2 a year ago, stopped due to working very late and now can pick it up again. This is not for a job or for school... its just for my own desire to learn AVR ASM (yes, I am that loony).
I made a simple program to help me explore the op codes and learn. It runs on an Arduino Uno board (ATMega328P-AU) and is programmed from within the Arduino environment (You can do AVR ASM and C directly with in the Arduino IDE).
All the program does is read the pin values in PORTD and write those bits to an array of LEDs I have tied to each pin in PORTB. So if PD3 has power, PB3 should light up.
All PORTD pins are set with no pull up or down resistors.
I only have trouble with the PB0 and PB1
It works as expected... EXCEPT.... the LEDs for PB0 and PB1 are always on.. and this seems to be driven from the bits in PORTD. Thus giving power to PD0 or PD1 is irrelevant since the LEDs are always on. I know PB0 and PB1 are for the UART... are they always held HIGH? Is that what the issue is??
Can some one please tell me (please remember I am still very much a beginner!) why this is happening and how to correct it. I figured out how to write a "0" to these two bits but then I can use the button for those two bits.
Thank you in advance. I am learning alone out of a bunch-a books and stuff I find on the internet.
BlinkTest4: // Note: you can have 000000000000000000001101 and just the LSB will be looked at, and then MSB //SER R16 // sets all bits in R16 to "1" LDI R16, 0 // if use LD instead of LDI, then the 0b111 would have been an address of the data OUT DDRB, R16 SER R16 //LDI R16, 255 OUT PORTB, R16 RJMP INIT INIT: //LDI R16, 0 CLR R16 OUT PORTB , R16 OUT DDRD, R16 RJMP MAIN MAIN: IN R16, PIND // This is necessary to turn the ever-on LEDs off... // and I can't use the button on them as well! // otherwise LEDs 0 and 1 on PORTB are always on! CBR R16 , 0 CBR R16 , 1 CBR R16 , 2 OUT PORTB, R16 RJMP MAIN RET