Zdravím, Mam menší problem s primem alebo s uloženim retazcem stringu do pole kere dalej možem v main využit a spracovavat. Ked primam jeden char tak to ide ale ked chcem prijat retazek už to nerobí nic. sem koncoch :/ a sem začatečnik robil sem to pomocou datasheetu plus neco z netu tak ked to bude cele zle snad ma neukamunejete
#include <avr/io.h>
#include <util/delay.h>
#include <stdlib.h>
#include <stdio.h>
#include <avr/interrupt.h>
#include "uart.h"
#include "lcd.h"
int main(){
char pole[16];
char text[32];
uart_init(4800);
lcd_init(LCD_DISP_ON);
lcd_clrscr();
lcd_gotoxy(0,1);
lcd_puts(" Funguju a Ahoj");
_delay_ms(2000);
lcd_clrscr();
while(1){
uart_getc(pole);
sprintf(text,"hodnota:%c",pole);
lcd_clrscr();
lcd_gotoxy(0,0);
lcd_puts(text);
_delay_ms(2000);
}
return 0;
}
ISR(USART_RXC_vect)
{
if (rx_pos == BUF_SIZE) rx_pos = 0;
if(rx_stav != RX_UKONCENE){
rx_buff[rx_pos] = UDR;
//ak prisiel ukoncovaci znak
if ((rx_buff[rx_pos] == '\r')|(rx_buff[rx_pos]=='\n')){
rx_buff[rx_pos+1] = '\0';
rx_stav = RX_UKONCENE;
}else{
rx_pos++;
}
}
}
unsigned char uart_gets(char* rx_pole){
if(rx_stav == RX_UKONCENE) {
strcpy(rx_pole, rx_buff);
rx_stav = RX_NEUKONCENE;
rx_pos = 0;
return 1;
}else{
rx_pole = 0;
return 0;
}
}