Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

send data to the serial port using proteus based ATmega16

Status
Not open for further replies.

aminanto

New Member
I recently made ​​a small project for my final project,
This project involves the transmission of data via the serial port.
I am using proteus to simulate the system as a whole and based on ATmega16.
since my laptop does not have a serial port so I
using Virtual Serial Port Emulator. While I use huperterminal to receive data transmitted by the microcontroller. I just do not have the data sent by the microcontroller.
Someone please help me, I've thought about it for hours and did not manage to make the data sent ..

This is a screenshot of proteus and code. ..
View attachment 68547View attachment 68547

Code:
//Program for ADC to read from channel 0 and show the 8 bit o/p on PORTB
// send the reading from ADC to Serial Port

#include <mega16.h>
#include <stdlib.h>
#include <delay.h>
#include <io.h>


#define ADC_VREF_TYPE 0x40
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((12000000/ (USART_BAUDRATE*16))) - 1)
//------------------------------------------------

void ADC_init(void) // Initialization of ADC
{
ADMUX=(1<<REFS0);
ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);    // faktor pembagi 128
}

void usart_init()
{
UCSRB |= (1 << RXEN) | (1 << TXEN);   // Turn on the transmission and reception 

circuitry
UCSRC |= (1 << URSEL) | (1<<USBS) | (1 << UCSZ0) | (1 << UCSZ1); 
// Use 8-bit character sizes
 
UBRRL = BAUD_PRESCALE; 
// Load lower 8-bits of the baud rate value into the low byte of the UBRR register
UBRRH = (BAUD_PRESCALE >> 8); // Load upper 8-bits of the baud rate value..
// into the high byte of the UBRR register
}

void usart_putch(unsigned char send)
{
while ((UCSRA & (1 << UDRE)) == 0); // Do nothing until UDR is ready..
// for more data to be written to it
UDR = send; // Send the byte 
}

/*void USART_transmit(unsigned char data)
{
  while((UCSRA & 0x20)==1)
  { 
  UDR=data; }
    }*/
/*void SEND_reading(unsigned char abc)
{
    unsigned char k,l,m;
    k=abc/100;
    l=(abc/10)%10;  
    m=abc%10;
    USART_transmit(k);
    USART_transmit(l);
    USART_transmit(m);
    USART_transmit(',');
    }  */
/*unsigned int ADC_read(unsigned char ch)
{
ch= ch & 0b00000111; // channel must be b/w 0 to 7
ADMUX |= ch; // selecting channel
 
ADCSRA|=(1<<ADSC); // start conversion
while(!(ADCSRA & (1<<ADIF))); // waiting for ADIF, conversion complete
ADCSRA|=(1<<ADIF); // clearing of ADIF, it is done by writing 1 to it
 
return ADCW;
}   */


// Read the AD conversion result
unsigned int ADC_read(unsigned char adc_input)
{
ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0b01000000;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==1);
ADCSRA|=0b00000;
return ADCW;
}


void main(void)
{
unsigned int value;
DDRB=0xFF;
DDRD=0x03;
ADC_init(); // Initialization of ADC
usart_init();
// ch=0;
while(1)
{
value=ADC_read(0);
value=value*500/1024;
PORTB=value;
//SEND_reading(value);
usart_putch(value);
delay_ms(10);
  } 
}


one more, I'm using code vision

I would greatly appreciate any help you guys ..
 
I think there is semething wrong with the code,
wHEN I connect the micro with VT directly without max232, result is the same ..

View attachment 68561

And here is the proteus file:
**broken link removed**

hex and prj files are not uploaded.
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top