Hi, I've only started learning AVR. I am trying to set up an ADC that reads in a value from a potentiometer, however the ADSC bit in the ADCSRA will not set despite my code and thus my conversion will not start.
I am using an ATMEGA328P (Arduino UNO) running with AtmelStudio 7 (assembly). The potentiometer input is the 5V pin and the output is analog pin A0 and of course GRND. I have checked the Data sheet and set the relevant bits accordingly however the ADSC bit does not get set.
Could anyone please assist? much appreciated
CONVERSION: ;R16 USED AS TEMP REGISTER LDI R16, 0b0000_0011 STS DIDR1, R16 LDI R16, 0b0000_0001 STS DIDR0, R16 LDI R19, 0b0000_0000 STS ADCSRB, R16 LDI R16, 0b1110_1111 ;ADEN ADSC ADATE ADIF_ADIE ADPS2 ADPS1 ADPS0 STS ADCSRA, R16 LDI R16, 0b0110_0000 ;REFS1 REFS0 ADLAR - _ MUX3 MUX2 MUX1 MUX0 STS ADMUX, R16 SEI BUSY: ;POLL FOR ADIF BIT LDS R19, ADCSRA SBRS R19, 6 ;CHECK IF ADIF BIT IN ADCSRA IS SET (IF BIT SET THEN CONVERSION COMPLETE) RJMP BUSY ;IF CONVERSION NOT COMPLETE RUN LOOP AND CHECK AGAIN LDS R18, ADCH ;TEST IF ADCH HIGH OR LOW BY TOGGLING POT OUT DDRB, R18 OUT PORTB, R18 RJMP CONVERSION ;REPEAT LOOP FOR CONTINUOUS CONVERSION