I am trying to get the ADC of the ATMEGA 328P to do a conversion with the use of interrupts and once the conversion is complete, I need it to print ^Conversion Complete^ on a 16x2 LCD.I am currently using Proteus simulator to observe these results. My problem is when the LCD does not print anything at all. The LCD initialization, delay and printing subroutines work fine when used alone, without the interrupts or the ADC conversion initialization. Im not sure if I have placed the interrupts in correct position or if I have used the memory allocations using .ORG correctly.My code is as below
ORG 0x00
JMP START
.ORG 0x002A ; Address of the ADC conversion complete interrupt
JMP ADC_vect
.ORG 0x0020 ; Address of the Timer0 overflow vector
JMP TIMER0_OVF_vect
.ORG 0x100
;string definitions
START:
LDI temp, HIGH(RAMEND)
OUT SPH, temp
LDI temp, LOW(RAMEND)
OUT SPL, temp
SENSOR_MAIN:
LDI temp, (1<<REFS0)
STS ADMUX, temp
LDI temp, (1<<ADEN)|(1<<ADATE)|(1<<ADIE)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0)
STS ADCSRA, temp
LDI temp, (1<<ADTS0)|(1<<ADTS1)|(1<<ADTS2)
STS ADCSRB, temp
LDI temp, (1 << TOIE0)
STS TIMSK0, temp
LDI temp,0x03
STS TCCR0B, temp
SEI
TIMER0_OVF_vect:
;setting up delay of 1ms
LDI temp, 131
OUT TCNT0, temp
LDS temp, ADCSRA
SBRS temp, ADSC
RJMP SKIP_ADC_START
;start ADC conversion
LDI temp, (1<<ADSC)
STS ADCSRA, temp
SKIP_ADC_START:
RETI
ADC_vect:
LDS temp, ADCSRA
SBRS temp, ADIF
RJMP NOT_COMPLETE
RCALL Conversion_Complete
LDI temp, (1<<ADIF)
STS ADCSRA, temp
NOT_COMPLETE:
RETI
Conversion_Complete:
LDI ZH, HIGH(conversion_string)
LDI ZL, LOW(conversion_string)
LDI temp, CMD_SET_BEGLINE
CALL lcd_write_string
LDI ZH, HIGH(complete_string)
LDI ZL, LOW(complete_string)
LDI temp, CMD_SET_BEGLINE
CALL lcd_write_string
RET