Rhizudin
Newbie level 4
- Joined
- Jun 26, 2013
- Messages
- 7
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,343
Hi! I have a project to read adc data from atmega8535 microcontroller to PC using serial. I use Codevision AVR for programming application.
I have try this code, but it just shown an unknown character like this -> ÿ
After that, i try to change this code :
to
But there is an error message " function argument #1 of type 'unsigned char' is incompatible with required parameter of type 'unsigned char *' "
So, whats wrong with my code? anyone know please ?
I have try this code, but it just shown an unknown character like this -> ÿ
Code:
#include <mega8535.h>
#include <stdio.h>
#include <delay.h>
#define mode_ADC 0x20
const long int osilator=4000000;
unsigned long int UBRR;
unsigned char dataadc;
//prototype function
unsigned char baca_adc (unsigned char pin_adc)
{
ADMUX=pin_adc |mode_ADC;
ADCSRA|=0x40;
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCH;
}
void InisialisasiUART( unsigned long int baud_rate );
void tampilan (void);
void ngurusinADC (void);
void main ( void )
{
DDRC=0xFF;
PORTC=0x00;
ngurusinADC();
InisialisasiUART(9600);
while (1)
{
tampilan();
dataadc=baca_adc (1);
delay_ms(1000);
};
}
void ngurusinADC (void)
{
//Inisialisasi ADC
DDRC=0xFF;
ADMUX=mode_ADC;
ADCSRA=0x86;
}
void InisialisasiUART ( unsigned long int baud_rate )
{
UBRR = (osilator/(16*baud_rate))-1;
UBRRL = UBRR;
UBRRH = UBRR>>8;
UCSRA = 0x00;
UCSRB = 0x18;
UCSRC = 0x86;
}
void tampilan (void)
{
putchar(dataadc);
}
After that, i try to change this code :
Code:
putchar(dataadc);
Code:
puts(dataadc);
So, whats wrong with my code? anyone know please ?