ATmega128 i dziwny problem :) - dlugie
kwia-Tec - 07-12-2006 22:45
ATmega128 i dziwny problem :) - dlugie Witam grupowiczow.
Przesiadlem sie z m8 na m128 i sie zdziwilem, bo program napisany
pod m8, na m128 nie dziala ... Oczywiscie pozmienialem wszystkie
potrzebne rejestry itp. Ale nie w tym problem, bo za duzo opowiadania
:).
Otoz wyglada to tak. Jest sobie testowy programik :
..nolist
..include "m128def.inc"
; ***** Constans ***************************************
..equ LENGTH=100
..def temp=r16
..def znak=r20
; ***Secure code****************************************
..list
..cseg ;Code segment
..org $0000
jmp reset ; Reset
..org $0024
jmp odbior ; USART0 RX Complete
;*************************************
; start main program
reset:
;set stack pointer to last internal RAM location
ldi temp,low(RAMEND)
out SPL,temp
ldi temp,high(RAMEND)
out SPH,temp
;uart
ldi temp,0
out UCSR0A,temp ;bez doublespeed, bez multiprocesor
ldi temp,0b10011000 ; int - en on rx, dis on tx, dis on empty, rx en,
tx en
out UCSR0B,temp
ldi temp,0b10000110 ; asynch, parity N, 1 stop, 8 bit
sts UCSR0C,temp
ldi temp,25
out UBRR0L,temp
ldi temp,0
sts UBRR0H,temp
ldi XL,low(bufor)
ldi XH,high(bufor)
;oblokowanie przerwan
sei
;***********************************
; glowna petla programu
kolko: rjmp kolko
; **** podprogramy
************************************************** **********
;********************************
;czeka na pusty bufor do wyslania po rs-sie
rs_wait: sbis UCSR0A,UDRE0
rjmp rs_wait
ret
;********************************
;wysyla znak z tempa na rs-a
tx_rs: rcall rs_wait
out UDR0,temp
ret
; ****** Interupts
************************************************** ***********
; get byte from rs
odbior:
in temp,SREG ;store flags
push temp
mov temp,XL ;show XL register
rcall tx_rs
in znak,UDR0 ;get byte from rs
out UDR0,znak ;echo
st X,znak ;add byte to bufor
ld temp,X ;show byte from bufor
rcall tx_rs
ldi temp,0
st X+,temp ;add 0 to end of bufor
ld temp,X ;show 0 :)
rcall tx_rs
pop temp
out SREG,temp
reti
; ***** Dane **************************************
;segment danych
..dseg
bufor: .byte LENGTH
----------------------------------------------------------------------------
----------------------------------------
Czyli w skrocie : 1 bajt to XL, 2 - odczytany znak z RS-a, 3 -
odczytany z bufora, 4 - powinien byc zawsze 0 (koniec danych w buforze)
A efektem tego programu jest :
2006-12-07 21:43:06.94 [TX] - 61
2006-12-07 21:43:06.97 [RX] - 60 61 61 00
2006-12-07 21:43:09.29 [TX] - 61
2006-12-07 21:43:09.34 [RX] - 61 61 61 00
2006-12-07 21:43:10.50 [TX] - 61
2006-12-07 21:43:10.54 [RX] - 62 61 61 1E
2006-12-07 21:43:12.25 [TX] - 61
2006-12-07 21:43:12.29 [RX] - 63 61 1E 00
2006-12-07 21:43:13.61 [TX] - 61
2006-12-07 21:43:13.65 [RX] - 64 61 01 00
2006-12-07 21:43:15.17 [TX] - 61
2006-12-07 21:43:15.22 [RX] - 65 61 01 00
2006-12-07 21:43:16.44 [TX] - 61
2006-12-07 21:43:16.48 [RX] - 66 61 61 00
2006-12-07 21:43:17.20 [TX] - 61
2006-12-07 21:43:17.25 [RX] - 67 61 61 00
2006-12-07 21:43:17.81 [TX] - 61
2006-12-07 21:43:17.84 [RX] - 68 61 01 00
2006-12-07 21:43:18.26 [TX] - 61
2006-12-07 21:43:18.31 [RX] - 69 61 61 00
2006-12-07 21:43:21.39 [TX] - 61
2006-12-07 21:43:21.44 [RX] - 6A 61 61 00
2006-12-07 21:43:22.15 [TX] - 61
2006-12-07 21:43:22.20 [RX] - 6B 61 61 00
2006-12-07 21:43:23.00 [TX] - 61
2006-12-07 21:43:23.04 [RX] - 6C 61 01 00
2006-12-07 21:43:23.73 [TX] - 61
2006-12-07 21:43:23.78 [RX] - 6D 61 60 00
2006-12-07 21:43:24.51 [TX] - 61
2006-12-07 21:43:24.56 [RX] - 6E 61 61 AE
2006-12-07 21:43:26.39 [TX] - 61
2006-12-07 21:43:26.44 [RX] - BF 33 78 06 CE 00 C0
2006-12-07 21:43:28.73 [TX] - 61
2006-12-07 21:43:28.79 [RX] - 00 86 FE 98 80
2006-12-07 21:43:31.56 [TX] - 61
2006-12-07 21:43:31.62 [RX] - 06 06 FE 80 F8
2006-12-07 21:43:34.25 [TX] - 61
2006-12-07 21:43:34.31 [RX] - 18 86 FE 98 FE
2006-12-07 21:43:35.69 [TX] - 61
2006-12-07 21:43:35.75 [RX] - 1E 86 FE FE 80 80
2006-12-07 21:43:37.45 [TX] - 61
2006-12-07 21:43:37.51 [RX] - 60 86 FE 80 06 00 FE
Reset procka .....
2006-12-07 21:43:56.79 [TX] - 62
2006-12-07 21:43:56.83 [RX] - 60 62 62 00
2006-12-07 21:43:58.76 [TX] - 62
2006-12-07 21:43:58.79 [RX] - 61 62 62 00
2006-12-07 21:44:00.40 [TX] - 62
2006-12-07 21:44:00.45 [RX] - 62 62 62 1E
2006-12-07 21:44:01.20 [TX] - 62
2006-12-07 21:44:01.25 [RX] - 63 62 1E 00
2006-12-07 21:44:01.89 [TX] - 62
2006-12-07 21:44:01.94 [RX] - 64 62 02 00
2006-12-07 21:44:02.58 [TX] - 62
2006-12-07 21:44:02.61 [RX] - 65 62 02 00
2006-12-07 21:44:03.33 [TX] - 62
2006-12-07 21:44:03.37 [RX] - 66 62 62 00
2006-12-07 21:44:04.01 [TX] - 62
2006-12-07 21:44:04.04 [RX] - 67 62 62 00
2006-12-07 21:44:04.61 [TX] - 62
2006-12-07 21:44:04.65 [RX] - 68 62 00 00
2006-12-07 21:44:05.11 [TX] - 62
2006-12-07 21:44:05.15 [RX] - 69 62 62 00
2006-12-07 21:44:05.65 [TX] - 62
2006-12-07 21:44:05.69 [RX] - 6A 62 62 00
2006-12-07 21:44:06.29 [TX] - 62
2006-12-07 21:44:06.34 [RX] - 6B 62 62 00
2006-12-07 21:44:06.81 [TX] - 62
2006-12-07 21:44:06.86 [RX] - 6C 62 02 00
2006-12-07 21:44:07.25 [TX] - 62
2006-12-07 21:44:07.29 [RX] - 6D 62 62 00
2006-12-07 21:44:07.73 [TX] - 62
2006-12-07 21:44:07.78 [RX] - 6E 62 62 AE
2006-12-07 21:44:08.26 [TX] - 62
2006-12-07 21:44:08.33 [RX] - BF C3 78 18 CE 00 C0
2006-12-07 21:44:13.76 [TX] - 62
2006-12-07 21:44:13.83 [RX] - 00 66 FE 66 80
2006-12-07 21:44:16.98 [TX] - 62
2006-12-07 21:44:17.04 [RX] - 06 06 FE 80 F8
2006-12-07 21:44:19.76 [TX] - 62
2006-12-07 21:44:19.83 [RX] - 18 66 FE 66 FE
2006-12-07 21:44:21.28 [TX] - 62
2006-12-07 21:44:21.34 [RX] - 1E 66 FE FE 80 80
2006-12-07 21:44:22.76 [TX] - 62
2006-12-07 21:44:22.83 [RX] - 60 66 FE E6 06 00 FE
2006-12-07 21:44:25.98 [TX] - 62
2006-12-07 21:44:26.04 [RX] - 66 66 FE 66 00
Reset procka ....
2006-12-07 21:44:44.76 [TX] - 63
2006-12-07 21:44:44.81 [RX] - 60 63 63 00
2006-12-07 21:44:46.39 [TX] - 63
2006-12-07 21:44:46.44 [RX] - 61 63 63 00
2006-12-07 21:44:47.14 [TX] - 63
2006-12-07 21:44:47.17 [RX] - 62 63 63 1E
2006-12-07 21:44:52.84 [TX] - 63
2006-12-07 21:44:52.87 [RX] - 63 63 1E 00
2006-12-07 21:44:54.64 [TX] - 63
2006-12-07 21:44:54.67 [RX] - 64 63 03 00
2006-12-07 21:44:57.76 [TX] - 63
2006-12-07 21:44:57.81 [RX] - 65 63 03 00
2006-12-07 21:44:59.81 [TX] - 63
2006-12-07 21:44:59.86 [RX] - 66 63 63 00
2006-12-07 21:45:00.89 [TX] - 63
2006-12-07 21:45:00.94 [RX] - 67 63 63 00
2006-12-07 21:45:01.61 [TX] - 63
2006-12-07 21:45:01.65 [RX] - 68 63 03 00
2006-12-07 21:45:02.42 [TX] - 63
2006-12-07 21:45:02.47 [RX] - 69 63 63 00
2006-12-07 21:45:03.28 [TX] - 63
2006-12-07 21:45:03.33 [RX] - 6A 63 63 00
2006-12-07 21:45:03.75 [TX] - 63
2006-12-07 21:45:03.79 [RX] - 6B 63 63 00
2006-12-07 21:45:04.36 [TX] - 63
2006-12-07 21:45:04.40 [RX] - 6C 63 03 00
2006-12-07 21:45:04.79 [TX] - 63
2006-12-07 21:45:04.84 [RX] - 6D 63 62 00
2006-12-07 21:45:05.26 [TX] - 63
2006-12-07 21:45:05.29 [RX] - 6E 63 63 AE
2006-12-07 21:45:06.03 [TX] - 63
2006-12-07 21:45:06.09 [RX] - BF F3 78 1E CE 00 C0
2006-12-07 21:45:08.12 [TX] - 63
2006-12-07 21:45:08.19 [RX] - 00 66 FE 66 80
2006-12-07 21:45:08.53 [TX] - 63
2006-12-07 21:45:08.59 [RX] - 06 86 98 F8
2006-12-07 21:45:08.90 [TX] - 63
2006-12-07 21:45:08.97 [RX] - 18 86 F8 FE
2006-12-07 21:45:09.39 [TX] - 63
2006-12-07 21:45:09.45 [RX] - 1E 66 FE FE 80 80
2006-12-07 21:45:09.87 [TX] - 63
2006-12-07 21:45:09.94 [RX] - 60 86 E0 06 00 FE
2006-12-07 21:45:12.75 [TX] - 63
2006-12-07 21:45:12.81 [RX] - 66 86 F8 00
Czy ktos potrafi to wyjasnic, bo ja nie mam pojecia o co chodzi.
1. Dlaczego po zapisaniu do bufora i odczytaniu z niego czasami sa inne
wartosci ?
Zauwazcie, podobienstwa gdy XL wynosi 64, 65, 68 i 6C...
2. Dlaczego gdy XL osiagnie wartosc 6E pozniej zaczynaja sie jaja ? I to
jakie :) Przeciez bufor jest ustawiony na 100 bajtow
Napewno cos zle robie, tylko co ? Juz nie mam pomyslow....
Prosze o jakies sugestie :)
pozdrawiam
kwia-Tec
Miller Artur - 07-12-2006 22:45
Użytkownik "kwia-Tec" <Krzys@spam.wsieci.net> napisał w wiadomości
news:ela14h$5e9$1@node4.news.atman.pl...
> Witam grupowiczow.
> Przesiadlem sie z m8 na m128 i sie zdziwilem, bo program napisany
> pod m8, na m128 nie dziala ... Oczywiscie pozmienialem wszystkie
> potrzebne rejestry itp. Ale nie w tym problem, bo za duzo opowiadania
> :).
> Otoz wyglada to tak. Jest sobie testowy programik :
>
[mlask]
a wyłaczył Waść zgodność z m103 ?
@
kwia-Tec - 07-12-2006 23:45
Użytkownik Miller Artur <armi@nowhere.com> w wiadomości do grup dyskusyjnych
napisał:ela1i9$vqj$1@news.interia.pl...
> a wyłaczył Waść zgodność z m103 ?
a wylaczyl Wasc, wylaczyl :)
Robert Z. - 08-12-2006 09:45
> A efektem tego programu jest :
>
>
> 2006-12-07 21:43:06.94 [TX] - 61
> 2006-12-07 21:43:06.97 [RX] - 60 61 61 00
Z tego wniosek ze w XL na poczatku jest $60 i jezeli w XH jest 0 to
zamazujesz rejestry procka;] Rejestry koncza sie na $00FF zatem poczatkowa
wartosc X'a powinna wskazywac na $0100, a blad jest tu:
ldi XL,low(bufor)
ldi XH,high(bufor)
niemam pojecia czemu kompilator ustawia poczatek .dseg na $0060, sproboj
zaraz za .dseg dac .org $0100
pozdrawiam
kwia-Tec - 09-12-2006 18:45
Użytkownik Robert Z. <mojejapko@jebajspam.insite.pl> w wiadomości do grup
dyskusyjnych napisał:elb81f$lcj$1@nemesis.news.tpi.pl...
> sproboj zaraz za .dseg dac .org $0100
pomoglo - serdeczne dzieki
pozdrawiam
kwia-Tec
zanotowane.pldoc.pisz.plpdf.pisz.plkonstruktor.keep.pl