Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Arduino - Remote control (RF-TX)
Makso,

ne znam odakle ti kasnjenje od jedne sekunde. To ne bi smelo da se desava ni kada koristis softverski uart. Da li si ti siguran da ti je MCU radi na 16MHz? Da li su ti osiguraci podeseni tako da ti MCU radi sa esternim kristalom? Prvo bi to trbali da definisemo. Takodje, iz koda izbaci sve komande koje su ti neki Delay.
Evo kako se radi sa hardverskim uart-om.
Pre svega ovoga treba podesiti pinove RX i TX
UCSR0A = 0b01000010;
UCSR0B = 0b00011000;
UCSR0C = 0b00000110;
UBRR0H = 0;
UBRR0L = 207; // 9600bps pri 16MHz

// Funkcija za slanje jednog bajta preko UART-a
void SendByte(unsigned char DataForSend)
{
UDR0 = DataForSend;
while(!(UCSR0A & 0x40));
UCSR0A |= 0x40;
}

// Funcija za prijem jednog bajta
unsigned char ByteReceive(void)
{
while(!(UCSR0A & 0x80));
return UDR0;
}

Ove dve funkcije zakucavaju procesor u while petlji, tj. koriste tzv. poolig metodu. Da ne bi stalno cekao u petlji da li je nesto stiglo ili ne, moze da napravis i sledecu funkciju:

unsigned char IsBytesAvialable()
{
if(UCSR0A & 0x80)
{return 0xFF; // Bajt je stigao
}
else
{
return 0x00; // Bajt nije stigao
}
}


Ovako mozes da koristi slanje.

SendByte('*');

Ovako mozes da radis prijem:

if(IsBytesAvialable)
{ ReceivedData = ByteReceive();
}

Ovo bi se sve koristilo u main-u. Ako ti treba bas nesto ozbiljo, onda se koristi prekidi (interapti) i brze od toga ne moze. Ostaje da se napravi parser poruka itd.
Reply


Messages In This Thread
Arduino - Remote control (RF-TX) - by Makso - 09-10-2016, 01:02 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-10-2016, 04:03 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-10-2016, 06:20 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 05:43 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 06:40 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 07:00 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 07:07 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 07:28 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 07:33 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 07:46 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-11-2016, 08:09 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-26-2016, 03:11 PM
RE: Arduino - Remote control (RF-TX) - by Omegakg - 09-26-2016, 04:52 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-26-2016, 06:31 PM
RE: Arduino - Remote control (RF-TX) - by Omegakg - 09-26-2016, 06:57 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-26-2016, 07:14 PM
RE: Arduino - Remote control (RF-TX) - by Omegakg - 09-26-2016, 08:54 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-26-2016, 10:01 PM
RE: Arduino - Remote control (RF-TX) - by Omegakg - 09-27-2016, 10:38 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-27-2016, 12:40 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 09-27-2016, 03:40 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 09-27-2016, 04:37 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-27-2016, 05:32 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 09-27-2016, 07:58 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-27-2016, 08:07 PM
RE: Arduino - Remote control (RF-TX) - by npejcic - 09-27-2016, 09:09 PM
RE: Arduino - Remote control (RF-TX) - by Omegakg - 09-27-2016, 10:33 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-27-2016, 10:44 PM
RE: Arduino - Remote control (RF-TX) - by npejcic - 09-28-2016, 08:48 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-28-2016, 11:45 AM
RE: Arduino - Remote control (RF-TX) - by npejcic - 09-28-2016, 06:33 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-28-2016, 06:48 PM
RE: Arduino - Remote control (RF-TX) - by npejcic - 09-28-2016, 07:11 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-28-2016, 07:19 PM
RE: Arduino - Remote control (RF-TX) - by npejcic - 09-29-2016, 09:32 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 10-03-2016, 10:46 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 10-06-2016, 09:32 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 10-06-2016, 10:20 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 10-20-2016, 10:59 AM
RE: Arduino - Remote control (RF-TX) - by npejcic - 10-20-2016, 04:10 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 10-20-2016, 06:17 PM
RE: Arduino - Remote control (RF-TX) - by npejcic - 10-20-2016, 08:16 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-18-2017, 03:28 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-18-2017, 07:28 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-18-2017, 08:04 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-19-2017, 01:20 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-18-2017, 09:29 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-18-2017, 11:24 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-19-2017, 09:25 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-19-2017, 12:08 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-19-2017, 07:31 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-27-2017, 04:31 PM
RE: Arduino - Remote control (RF-TX) - by vsavic - 02-27-2017, 04:43 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-27-2017, 04:56 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 02-27-2017, 07:34 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-27-2017, 10:56 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 02-28-2017, 01:59 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-28-2017, 09:17 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 03-26-2017, 11:41 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 09-15-2017, 11:16 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 12-28-2017, 10:37 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 12-29-2017, 12:29 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 12-29-2017, 01:05 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-03-2018, 12:40 AM
RE: Arduino - Remote control (RF-TX) - by mikikg - 01-03-2018, 08:28 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-05-2018, 05:49 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-05-2018, 11:38 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-06-2018, 12:06 AM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-06-2018, 12:12 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-06-2018, 12:33 AM
RE: Arduino - Remote control (RF-TX) - by gorankg - 01-06-2018, 08:45 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-06-2018, 08:34 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-17-2018, 08:28 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-18-2018, 06:05 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-19-2018, 06:38 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-19-2018, 11:19 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-21-2018, 03:28 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-21-2018, 01:26 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-21-2018, 05:28 PM
RE: Arduino - Remote control (RF-TX) - by vojinilic - 01-21-2018, 05:51 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 01:12 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 01:40 AM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-22-2018, 01:54 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 02:03 AM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-22-2018, 10:33 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 01:51 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-22-2018, 03:19 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-22-2018, 03:50 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 01-22-2018, 04:00 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 09:12 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-22-2018, 10:48 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-22-2018, 11:12 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-23-2018, 01:22 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-23-2018, 01:20 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-23-2018, 03:18 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-23-2018, 07:20 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 01-23-2018, 07:26 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-23-2018, 03:53 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-23-2018, 10:21 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-23-2018, 11:47 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-24-2018, 04:12 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-24-2018, 04:46 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-24-2018, 05:20 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-24-2018, 05:52 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 01-24-2018, 06:30 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-24-2018, 09:37 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-25-2018, 02:01 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-25-2018, 01:54 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-25-2018, 02:35 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-26-2018, 12:34 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-26-2018, 12:57 PM
RE: Arduino - Remote control (RF-TX) - by me[R]a - 01-26-2018, 04:05 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-26-2018, 09:08 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-31-2018, 09:02 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-31-2018, 09:39 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 01-31-2018, 10:14 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-02-2018, 06:27 PM
RE: Arduino - Remote control (RF-TX) - by gorankg - 02-02-2018, 09:35 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-02-2018, 11:33 PM
RE: Arduino - Remote control (RF-TX) - by mikikg - 02-03-2018, 10:14 AM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-03-2018, 02:13 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 02-03-2018, 08:59 PM
RE: Arduino - Remote control (RF-TX) - by Makso - 05-26-2018, 12:03 PM

Forum Jump:


Users browsing this thread: 20 Guest(s)