The following is a code snippet I am running on the attiny427. The USART should basically produce a repeating data transmission of 0x0F using asynchornous 9600N1 mode.
#define USART0_BAUD_RATE(BAUD_RATE) ((float)(20000000 * 64 / (16 * (float)BAUD_RATE)) + 0.5) #define TXD_PB 2 int main(void){ CCP = CCP_IOREG_gc; //Configuration Change Protection CLKCTRL.OSC20MCALIBA = 13; //Calibration for 20MHz PORTB.DIR |= (1 << TXD_PB); //Set TXD as output pin sei(); // Global interrupt enable //Serial data transmission USART0.CTRLB |= USART_TXEN_bm; //Tx enable PORTB.PIN2CTRL = PORT_PULLUPEN_bm; //Enable pull up resistor for TxD USART0.BAUD = (uint16_t)USART0_BAUD_RATE(9600); //9600 Baud USART0.CTRLC = USART_CHSIZE_8BIT_gc; //8 bit data USART0.CTRLA = USART_TXCIE_bm; //Enable USART Transmit Complete Interrupt Enable USART0.TXDATAL = 0x0F; //First data } ISR(USART0_TXC_vect){ //Transmission complete interrupt USART0.STATUS |= USART_TXCIE_bm; //Clear the transmit complete interrupt flag USART0.TXDATAL = 0x0F; //Next data }
On the oscilloscope, the waveform looks like as shown in the attached image. I have identified the start and stop bits and the 8 data bits. But there is one extra bit that I am unable to identify. It looks like a "1" after the start bit, but the datasheet does not make any reference to such a bit. Any suggestions or clues would be appreciated.