nntp2http.com
Posting
Suche
Optionen
Hilfe & Kontakt

USART ATMEGA32 ,UBRRH e UCSRC ..inseparabili

Von: blisca (bliscachiocciolinatiscalipuntoit@sistrix.com) [Profil]
Datum: 06.07.2008 09:38
Message-ID: <48707686$0$35956$4fafbaef@reader2.news.tin.it>
Newsgroup: it.hobby.elettronica.digitale
Chiedo aiuto

se non ho capito male questi registri condividono gli stessi  I/O

per cui se voglio scrivere in USRC devo prima settare il bit URSEL  e se
voglio scrivere in UBRRH devo resettarlo,
invece sia in simulazione che nella realtà appare che quello che faccio ad
un registro avviene nell'altro

es:  se scrivo 1 in UCSZ0 e UCSZ1 con URSEL=1 scrivo   1 nei corrispondenti
bit di UBRRH

se poi voglio ripulire UBRRH  mettendo prima URSEL=0 avviene che UBRRH=0
renda a nche UCRSC=0



UCSRC =UCSRC & 0x7F;//porto  esplicitamente URSEL=0 ,non si sa mai
UBRRH=0;
UBRRL=1
UCSRA=UCSRA | (1<<PE )|(1<<U2X);
UCSRB=UCSRB  &(0xFF - (1<<UCSZ2)) | (1<<RXEN ) |(1<<TXEN) ;

UCSRC =  UCSRC | 0x80;// setto URSEL da solo prima di ogni operazione su
UCSRC
UCSRC =UCSRC  |(1<<USBS);
UCSRC =UCSRC  |(3 <<UCSZ0);//ok,ho settato i bit che mi interessavano
UCSRC =UCSRC & 0x7F;//URSEL=0
UBRRH=0;// dovrebbe agire solo su UBRRH  invece  ho UCSRC=0



dice il pdf di Atmega32
When doing a write access of this I/O location, the high bit of the value
written, the USART Register
Select (URSEL) bit, controls which one of the two registers that will be
written. If URSEL is

zero during a write operation, the UBRRH value will be updated. If URSEL is
one, the UCSRC

setting will be updated



grazie





[ Auf dieses Posting antworten ]