Hi, I begin explore ATtiny804, and wrote a program for USART (from internet):
ldi r16,low(fBAUD) ;load low value of fBAUD as calculated in the formula provided above
ldi r17,high(fBAUD) ;load high value of fBAUD as calculated in the formula provided above
sts USART0_BAUD,r16 ;store low fBAUD in BAUD register
sts USART0_BAUD + 1,r17 ;store low fBAUD in BAUD register
ldi r16,USART_TXEN_bm ;0b01000000 ,(1<<6) ,bitmask value to enable USART transmit
sts USART0_CTRLB,r16 ;store TXEN in USART_CTRLB register
sts PORTB_DIR,r16 ;set portB PB2 direction as output
sts PORTB_OUT,r16 ;set portB PB2 as 1 or +ve
lds r16,USART0_STATUS ;copy USART status register to r16
sbrs r16,5 ;skip next instruction if bit 5 is 1
rjmp soros ;if DREIF = 0 ,bit 5 in r16 is 0 then loop back to sendbyte until DREIF = 1
sts USART0_TXDATAL,r17 ;store r16 in TXDATAL transmit data low register
when I send a caracter, it is invert on TXD pin.
in IDLE state, TXD pin is low!!!
Have an idea any body?
lesson learned :don't stop program (BREAKPOINT) before transmit end!!!!!!!!!!!!!!!!