Question: Please convert this C code into assembly: #include #define F_CPU 16000000UL #define BAUD 9600 #define MYUBRR F_CPU/16/BAUD-1 #include util/delay.h void adc_init() { // AREF =

Please convert this C code into assembly:
#include
#define F_CPU 16000000UL
#define BAUD 9600
#define MYUBRR F_CPU/16/BAUD-1
#include "util/delay.h"
void adc_init()
{
// AREF = AVcc
ADMUX = (1<
// ADC Enable and prescaler of 128
// 16000000/128 = 125000
ADCSRA = (1<
}
void USART_Init( unsigned int ubrr)
{
UBRR0H = (unsigned char)(ubrr>>8);
UBRR0L = (unsigned char)ubrr;
/*Enable receiver and transmitter */
UCSR0B = (1<
/* Set frame format: 8data, 2stop bit */
UCSR0C = (1<
}
void USART_Transmit( unsigned char data )
{
while(!(UCSR0A & (1<
UDR0 = data;
}
void SendString(char *StringPtr)
{
while(*StringPtr != 0x00)
{
USART_Transmit(*StringPtr);
StringPtr++;
}
}
uint16_t adc_read(uint8_t ch)
{
// select the corresponding channel 0~7
// ANDing with 7? will always keep the value
// of ch between 0 and 7
ch &= 0b00000111; // AND operation with 7
ADMUX = (ADMUX & 0xF8)|ch; // clears the bottom 3 bits before ORing
// start single conversion
// write 1? to ADSC
ADCSRA |= (1<
// wait for conversion to complete
// ADSC becomes 0? again
// till then, run loop continuously
while(ADCSRA & (1<
return (ADC);
}
int main(void)
{
adc_init();
DDRC = 0b00000000;
USART_Init(MYUBRR);
unsigned int adc_value;
while(1)
{
adc_value=adc_read(0x00);
StringPtr *adc_valueStr = itoa(adc_value,adc_valueStr,10);
SendString(adc_value+"");
SendString(" ");
_delay_ms(1000);
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!