Posted on:
Attached files:Hey, I am a novice in the microcontroller and i have since one Week a Problem. I engraved this code below on mysmatcontrolM8 (s. picture). But, i obtain only weird character although it is working property on STK500 with atmega8. I have already verified the frequenz, the Baud Rate and all are OK. However, i obtain only weird character I viewed the mysmartcontrolM8 product description: power supply via USB connection, 5 V or 3.3 V. I think, that maybe the failing is the diference between the power supply of my PC and mysmatcontrolM8 (atmega8) !!! is that right!?! And please which transformer can i use? Or, where is my fault!?! can somebody help me!!! thank you
#ifndef F_CPU /* In the new version of the WinAVR/Mfile Makefile guideline One can defined F_CPU in the Makefile, a repeated definition here would lead to a compiler warning . therefore "prevention" through #ifndef/#endif This "Prevention" can lead to Debugger, if AVRStudio use a another, not the hardware fitting Clock rate: Then the following definition doesn't use, but instead the default value (1 MHz?) of AVRStudio - hence the Output of a warning if F_CPU yet does not define:*/ #warning "F_CPU was not defined yet, now make up with 3686400" #define F_CPU 3686400L // Systemtakt in Hz - define as long>> Without errors in the computation #endif #define BAUD 9600L #define UBRR_VAL ((F_CPU+BAUD * 8)/(BAUD*16)-1) //clever round #define BAUD_REAL (F_CPU/(16*(UBRR_VAL+1))) //real baud rate #define BAUD_ERROR ((BAUD_REAL*1000)/BAUD-1000) //Error per thousand #if ((BAUD_ERROR>10)||(BAUD_ERROR<-10)) #error Systematic error in the baud rate more than 1% and thus too high! #endif #include <avr/io.h> #include <stdlib.h> #include <inttypes.h> #include <util/delay.h> void USART_Init(void) { UBRRH = (unsigned char)(UBRR_VAL>>8); // Set baud rate UBRRL = (unsigned char)UBRR_VAL; UCSRB |= (1<<RXEN)|(1<<TXEN); // Enable receiver and transmitter UCSRC = (1<<URSEL) | (1<<UCSZ0)|(1<<UCSZ1); // Set frame format: 8data, 1stop bit }//end USART_Init() void USART_Putc(unsigned char c) { while (!(UCSRA & (1<<UDRE))); // Do nothing until data have been transmited UDR = c; // Put data into Buffer, sends the data _delay_ms(10); }//end USART_Putc() void USART_Puts (char *string) { while( *string != '\0' ) //as long as *string != '\0' so unlike the "stringer end-character" { USART_Putc(*string); string++; } }//end USART_Puts() int main(void) { USART_Init(); USART_Puts("\r\n"); while(1) { USART_Puts("Hey !!!!"); } return 0; } //end main() |
Posted on:
How did you connect the board to your PC? I wonder about the physical connection. The reason why I'm asking is: I miss to see some kind of level converter on the board (which doesn't necessarily mean it's not there).
Posted on:
Hey, thank you for your interrest. I have connected on PC over the USB interface, which provides a virtual COM3-Port to the PC. greet
Posted on:
I see. I assume you've made sure the baudrate is correct at 9600? If so, I'm running out of ideas.
Posted on:
Is your clock really 3.68 MHz? By default the ATmega8 is running on the internal 1 MHz RC oscillator. Make sure you have set all the necessary fusebits for running with the external crystal (see datasheet).
Posted on:
hey, i have it. all is ok. except that during all this time, I compiled the bad .exe file. stupid! thank all

