 |

|
Elektronika.lt portalo forumas
Jūs esate neprisijungęs lankytojas. Norint dalyvauti diskusijose, būtina užsiregistruoti ir prisijungti prie forumo.
Prisijungę galėsite kurti naujas temas, atsakyti į kitų užduotus klausimus, balsuoti forumo apklausose.
Administracija pasilieka teisę pašalinti pasisakymus bei dalyvius,
kurie nesilaiko forumo taisyklių.
Pastebėjus nusižengimus, prašome pranešti.
Dabar yra 2025 09 13, 06:52. Visos datos yra GMT + 2 valandos.
|
|
|
 |
Forumas » Mikrovaldikliai » at90s2313 UART
|
Jūs negalite rašyti naujų pranešimų į šį forumą Jūs negalite atsakinėti į pranešimus šiame forume Jūs negalite redaguoti savo pranešimų šiame forume Jūs negalite ištrinti savo pranešimų šiame forume Jūs negalite dalyvauti apklausose šiame forume
|
|
|
Puslapis 1 iš 2 Pereiti prie 1, 2 Toliau |
|
 |
at90s2313 UART |
Parašytas: 2006 05 03, 22:48 |
|
|
|
gal kas turit siam mazam procui kodu pvz, kaip uart realizuoti....
Ideja butu tokia kad tam tikra mygtuka (kojai paduota signala) paspaudzia per uart isduota, tarkim teksta "testas111", kita mygtuka paspaudzia "testas2222" ar panasiai...
Ieskojau pavyzdziu ant "CodeVisionAVR" internete tai nelabai ir kaip randasi...
Is anksto labai dekingas... |
|
|
|
|
 |
?? :/ |
Parašytas: 2006 05 15, 10:05 |
|
|
|
Negi nera kasgaletu padet, visi tokie uzimti.... |
|
|
|
|
 |
at90s2313 UART |
Parašytas: 2006 05 15, 11:00 |
|
|
|
.equ CLOCK = 1000000
.equ BAUD = 9600
.equ UBRRVAL = CLOCK/(BAUD*16)-1
.....................
; Baudrate setup
ldi temp, LOW(UBRRVAL)
out UBRRL, temp
ldi temp, HIGH(UBRRVAL)
out UBRRH, temp
; Frame-Format: 8 Bit
ldi temp, (1<<URSEL)|(3<<UCSZ0)
out UCSRC, temp
sbi UCSRB,TXEN ; TX active
;......
sbis PINB,PINB1 ;paspaustas PINB1?
rjmp Yes ;tipo taip
;...
Yes:
ldi r16, 'Y'
rcall serout
;....
serout:
sbis UCSRA,UDRE
rjmp serout
out UDR, r16
ret
; Iškarpiau ant smūgio, tkiuosi, nieko nepraleidau.. |
|
|
|
|
 |
at90s2313 UART |
Parašytas: 2006 05 16, 15:59 |
|
|
|
jei ant codevision, tai nieko sunkaus, sukonfiguruok, kad butu naudojasmas uart kaip tu nori, tada tiesiog rasyk kur nori
printf("testas");
asamblerio kalba nera prasmes naudortis ant avr, atmintes labai daug, tai taupyti nereikia |
|
|
|
|
 |
 |
at90s2313 UART |
Parašytas: 2006 05 16, 17:44 |
|
|
|
#include <90s2313.h>
#define RXB8 1
#define TXB8 0
#define OVR 3
#define FE 4
#define UDRE 5
#define RXC 7
#define FRAMING_ERROR (1<<FE)
#define DATA_OVERRUN (1<<OVR)
#define DATA_REGISTER_EMPTY (1<<UDRE)
#define RX_COMPLETE (1<<RXC)
// UART Receiver buffer
#define RX_BUFFER_SIZE 8
char rx_buffer[RX_BUFFER_SIZE];
#if RX_BUFFER_SIZE<256
unsigned char rx_wr_index,rx_rd_index,rx_counter;
#else
unsigned int rx_wr_index,rx_rd_index,rx_counter;
#endif
// This flag is set on UART Receiver buffer overflow
bit rx_buffer_overflow;
// UART Receiver interrupt service routine
interrupt [UART_RXC] void uart_rx_isr(void)
{
char status,data;
status=USR;
data=UDR;
if ((status & (FRAMING_ERROR | DATA_OVERRUN))==0)
{
rx_buffer[rx_wr_index]=data;
if (++rx_wr_index == RX_BUFFER_SIZE) rx_wr_index=0;
if (++rx_counter == RX_BUFFER_SIZE)
{
rx_counter=0;
rx_buffer_overflow=1;
};
};
}
#ifndef _DEBUG_TERMINAL_IO_
// Get a character from the UART Receiver buffer
#define _ALTERNATE_GETCHAR_
#pragma used+
char getchar(void)
{
char data;
while (rx_counter==0);
data=rx_buffer[rx_rd_index];
if (++rx_rd_index == RX_BUFFER_SIZE) rx_rd_index=0;
#asm("cli")
--rx_counter;
#asm("sei")
return data;
}
#pragma used-
#endif
// UART Transmitter buffer
#define TX_BUFFER_SIZE 8
char tx_buffer[TX_BUFFER_SIZE];
#if TX_BUFFER_SIZE<256
unsigned char tx_wr_index,tx_rd_index,tx_counter;
#else
unsigned int tx_wr_index,tx_rd_index,tx_counter;
#endif
// UART Transmitter interrupt service routine
interrupt [UART_TXC] void uart_tx_isr(void)
{
if (tx_counter)
{
--tx_counter;
UDR=tx_buffer[tx_rd_index];
if (++tx_rd_index == TX_BUFFER_SIZE) tx_rd_index=0;
};
}
#ifndef _DEBUG_TERMINAL_IO_
// Write a character to the UART Transmitter buffer
#define _ALTERNATE_PUTCHAR_
#pragma used+
void putchar(char c)
{
while (tx_counter == TX_BUFFER_SIZE);
#asm("cli")
if (tx_counter || ((USR & DATA_REGISTER_EMPTY)==0))
{
tx_buffer[tx_wr_index]=c;
if (++tx_wr_index == TX_BUFFER_SIZE) tx_wr_index=0;
++tx_counter;
}
else
UDR=c;
#asm("sei")
}
#pragma used-
#endif
// Standard Input/Output functions
#include <stdio.h>
// Declare your global variables here
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTB=0x00;
DDRB=0x00;
// Port D initialization
// Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
TCCR0=0x00;
TCNT0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1 output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
OCR1H=0x00;
OCR1L=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
GIMSK=0x00;
MCUCR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
// UART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// UART Receiver: On
// UART Transmitter: On
// UART Baud rate: 9600
UCR=0xD8;
UBRR=0x33;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
// Global enable interrupts
#asm("sei")
while (1)
{
// Place your code here
};
}
--------------------
Kuriuoj vietoj kintamasis del duomenu...?
Tai yra kaip pvz parasyt kas atliktu toki veiksma <<kojai paduota signala, paspaudzia per uart isduota, tarkim teksta "testas111", kita mygtuka paspaudzia "testas2222" ar panasiai... >> |
|
|
|
|
 |
 |
at90s2313 UART |
Parašytas: 2006 05 16, 18:09 |
|
|
|
kokiu dar duomenu kintamasis? jei del uart grecio ir parametru tai naudok wizarda. arba jei reikai koreguoti tai cias iesko // UART initialization
ir skaityk datasheeta. jei del grecio tai UBRR registras.
del signalo padavimo nera taip elementaru, gali naudoti koju skanavima, arba pertraukimus. kaip tai daroma atskira tema, ir daug buvo kalbeta apie mygtuku naudojima.
pavyzdys: (reikia paduoti korpusa i A porto 1 ir 2 iejimus)
DDRA=0x0 //portas A visi iejimai
PORTA=0xff //ijungiame pullup funkcija
while (1)
{
if (PORTA.1==0){ printf("testas1"); delay_ms(100);}
if (PORTA.2==0) { printf("testas2"); delay_ms(100);}
} |
|
|
|
|
 |
 |
??? |
Parašytas: 2006 05 16, 21:51 |
|
|
|
/*****************************************************
This program was produced by the
CodeWizardAVR V1.24.6 Professional
Automatic Program Generator
© Copyright 1998-2005 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
e-mail:office@hpinfotech.com
Project :
Version :
Date : 16.05.2006
Author : F4CG
Company : F4CG
Comments:
Chip type : AT90S2313
Clock frequency : 11,059000 MHz
Memory model : Tiny
External SRAM size : 0
Data Stack size : 32
*****************************************************/
#include <90s2313.h>
#define RXB8 1
#define TXB8 0
#define OVR 3
#define FE 4
#define UDRE 5
#define RXC 7
#define FRAMING_ERROR (1<<FE)
#define DATA_OVERRUN (1<<OVR)
#define DATA_REGISTER_EMPTY (1<<UDRE)
#define RX_COMPLETE (1<<RXC)
// UART Receiver buffer
#define RX_BUFFER_SIZE 8
char rx_buffer[RX_BUFFER_SIZE];
#if RX_BUFFER_SIZE<256
unsigned char rx_wr_index,rx_rd_index,rx_counter;
#else
unsigned int rx_wr_index,rx_rd_index,rx_counter;
#endif
// This flag is set on UART Receiver buffer overflow
bit rx_buffer_overflow;
// UART Receiver interrupt service routine
interrupt [UART_RXC] void uart_rx_isr(void)
{
char status,data;
status=USR;
data=UDR;
if ((status & (FRAMING_ERROR | DATA_OVERRUN))==0)
{
rx_buffer[rx_wr_index]=data;
if (++rx_wr_index == RX_BUFFER_SIZE) rx_wr_index=0;
if (++rx_counter == RX_BUFFER_SIZE)
{
rx_counter=0;
rx_buffer_overflow=1;
};
};
}
#ifndef _DEBUG_TERMINAL_IO_
// Get a character from the UART Receiver buffer
#define _ALTERNATE_GETCHAR_
#pragma used+
char getchar(void)
{
char data;
while (rx_counter==0);
data=rx_buffer[rx_rd_index];
if (++rx_rd_index == RX_BUFFER_SIZE) rx_rd_index=0;
#asm("cli")
--rx_counter;
#asm("sei")
return data;
}
#pragma used-
#endif
// UART Transmitter buffer
#define TX_BUFFER_SIZE 8
char tx_buffer[TX_BUFFER_SIZE];
#if TX_BUFFER_SIZE<256
unsigned char tx_wr_index,tx_rd_index,tx_counter;
#else
unsigned int tx_wr_index,tx_rd_index,tx_counter;
#endif
// UART Transmitter interrupt service routine
interrupt [UART_TXC] void uart_tx_isr(void)
{
if (tx_counter)
{
--tx_counter;
UDR=tx_buffer[tx_rd_index];
if (++tx_rd_index == TX_BUFFER_SIZE) tx_rd_index=0;
};
}
#ifndef _DEBUG_TERMINAL_IO_
// Write a character to the UART Transmitter buffer
#define _ALTERNATE_PUTCHAR_
#pragma used+
void putchar(char c)
{
while (tx_counter == TX_BUFFER_SIZE);
#asm("cli")
if (tx_counter || ((USR & DATA_REGISTER_EMPTY)==0))
{
tx_buffer[tx_wr_index]=c;
if (++tx_wr_index == TX_BUFFER_SIZE) tx_wr_index=0;
++tx_counter;
}
else
UDR=c;
#asm("sei")
}
#pragma used-
#endif
// Standard Input/Output functions
#include <stdio.h>
// Declare your global variables here
void main(void)
{
char k;
// Declare your local variables here
// Input/Output Ports initialization
// Port B initialization
// Func7=Out Func6=Out Func5=Out Func4=Out Func3=Out Func2=Out Func1=Out Func0=Out
// State7=1 State6=0 State5=0 State4=1 State3=1 State2=0 State1=0 State0=1
PORTB=0x99;
DDRB=0xFF;
// Port D initialization
// Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In
// State6=T State5=T State4=T State3=T State2=T State1=T State0=T
PORTD=0x00;
DDRD=0x00;
// Timer/Counter 0 initialization
// Clock source: System Clock
// Clock value: Timer 0 Stopped
TCCR0=0x00;
TCNT0=0x00;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: Timer 1 Stopped
// Mode: Normal top=FFFFh
// OC1 output: Discon.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare Match Interrupt: Off
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
OCR1H=0x00;
OCR1L=0x00;
// External Interrupt(s) initialization
// INT0: Off
// INT1: Off
GIMSK=0x00;
MCUCR=0x00;
// Timer(s)/Counter(s) Interrupt(s) initialization
TIMSK=0x00;
// UART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// UART Receiver: On
// UART Transmitter: On
// UART Baud rate: 9600
UCR=0xD8;
UBRR=0x47;
// Analog Comparator initialization
// Analog Comparator: Off
// Analog Comparator Input Capture by Timer/Counter 1: Off
ACSR=0x80;
// Global enable interrupts
#asm("sei")
while (1)
{
// Place your code here
k=getchar();
putchar(k);
};
}
---------
Pabandziau toki koda.
Turetu ka gaves is PC siusti atgal... bet neveikia sis kodas ant CODEVICIONAVR... Gal kas turit kokiu tai pastabu...
Beje jei kam nesunku galetumet duot IAR ne demo licenzija..... anksciau su ja programuodavau kol baigesi demo laikas..... |
|
|
|
|
 |
 |
at90s2313 UART |
Parašytas: 2006 05 16, 22:18 |
|
|
|
del licenzijos negaliu padeti, atsisiusk pilma versija per emule.
k=getchar();
putchar(k);
turetu veikti per pradek nuo printf
while (1)
{
// Place your code here
printf("abc");
};
jei veikia tada gali ziureti toliau, ir ar pajungei konverteri is ttl i com, jingdamas prie kompiuterio? ir dar ar tesingai nustatei procesoriaus greiti. gali buti fuse bitai blogai nukonfiguruoti.
ps. idomu is kur toki kvarca gavai 11.05M gal sakai ir tau nuo telekomo aparaturos atliko? |
|
|
|
|
 |
?? |
Parašytas: 2006 05 16, 22:43 |
|
|
|
|
 |
at90s2313 UART |
Parašytas: 2006 05 16, 22:56 |
|
|
|
del to perspejimo tai tavo procesorisu per silpnas biski, arba tiesiog padidink stack size kaip sako.
bet kaip saku pradziai padaryk kad tiesiog spausdintu betka. as taip visada pradedu, nes visokiu problemu buna. |
|
|
|
|
 |
at90s2313 UART |
Parašytas: 2006 05 16, 23:15 |
|
|
|
Na pabandysiu ryt vakarop.... gal pavyks,,,
Beje tu klp randiesi....? |
|
|
|
|
 |
at90s2313 UART |
Parašytas: 2006 05 18, 21:59 |
|
|
|
Na keista su printf nepavyksta. Bet parasius :
k=getchar();
putchar(k);
Ka i vedi ta ir isveda, daba kaip ir gerai buva klaida su baudreitu....
Bet jei parasau :
k=getchar();
putchar("Labas");
ivedus bet koki simboli kad parasytu "labas". Nevykdo.... Heroglifus raso....
Gal kas turit minciu kaip tai padaryti... |
|
|
|
|
 |
at90s2313 UART |
Parašytas: 2006 05 18, 23:21 |
|
|
|
putchat negalima zodzio siusti
reikia
putchar ('x') ne " o ' naudok ir viena raide vienu metu
bet ar esi isitikines kad gretis teisingai nustatytas, nes tas man buna dazniausia problema |
|
|
|
|
 |
at90s2313 UART |
Parašytas: 2006 05 18, 23:54 |
|
|
|
Na katik pabandziau:
putchar ('x');
toki varianta
putchar ("x");
Jokio praktiskai skirtumo greicius savo kompo keitelioju visvien heroglifai....
printf("x");
kitokius heroglifus meta....
Nepagaunu kampo...
Jei padarau kad koki simboli priema toki ir attiduotu, tada viska gerai bet kai noriu kad kazkoki is saves simboli ar tuo labiau zody... nieka nesigauna... :/ labai keista... |
|
|
|
|
|
 |
Google paieška forume |
|
 |
Naujos temos forume |
|
 |
FS25 Tractors
Farming Simulator 25 Mods,
FS25 Maps,
FS25 Trucks |
 |
ETS2 Mods
ETS2 Trucks,
ETS2 Bus,
Euro Truck Simulator 2 Mods
|
 |
FS22 Tractors
Farming Simulator 22 Mods,
FS22 Maps,
FS25 Mods |
 |
VAT calculator
VAT number check,
What is VAT,
How much is VAT |
 |
Dantų protezavimas
All on 4 implantai,
Endodontija mikroskopu,
Dantų implantacija |
 |
FS25 Mods
FS25 Maps,
FS25 Cheats,
FS25 Install Mods |
 |
FS25 Mods
Farming Simulator 25 Mods,
FS25 Maps |
 |
ATS Trailers
American Truck Simulator Mods,
ATS Trucks,
ATS Maps |
 |
Fun football drills
Football Training Equipment,
Defending drills football,
Kids football training kit |
|

|
 |