Hi freaks!
I have began work with the new attiny series that currently has no examples online that I can find. Tiny's in general don't appear to have any examples in AS7 either.
I have been trying to get Rx working. I can verify that the signal going in is at 3.3v and looks perfect on the scope for timing, nice square edges and correct bit settings.
My code thus far is as follows:
#define BAUD_RATE 103 void Uart_Init(void) { //PB2 - Tx. //PB3 - Rx. PORTB.DIRSET |= (1<<2); PORTB.OUTSET |= (1<<2); //don't use interrupts, don't want to delay the pwm... USART0.CTRLC = 0x03; //set character size to 8. parity = none. stop bits = 1. async usart. USART0.BAUDH = (uint8_t)(BAUD_RATE>>8); //baudRegVal = 64*clk/(s*baud), where in normal mode s = 16. in x2 rate, s = 8. USART0.BAUDL = (uint8_t)(BAUD_RATE); USART0.CTRLB = (1<< RXEN) | (1<< TXEN); //enable rx and tx } static void Uart_ServiceRx(void) { if ((PORTB.IN & (1<<3)) && (USART0.STATUS & (1<<7))) { uint8_t byte = 0; byte = USART0.RXDATAL; if (byte != 0) { volatile int x = 6; x++; } } }
Polling the "UART0.STATUS" register for the highest bit is supposed to be an Rx Receive complete flag and is set high when there is unread data. But my unread data is ALWAYS 0x00.
Since the microchip takeover I have noticed that all of the new chips now have errata, which is a little concerning, but nonetheless they usually have work arounds. Reading the Errata, they state this very issue:
40.1.7 USART 1 – Frame error on previous message may cause false start bit detection If receiving a frame with RXDATAH.FERR set and reading the RXDATAL before the RxD line goes high, will trigger a false start bit detection. Fix/Workaround: Wait for the RxD pin to go high before reading RXDATA, for instance by polling the bit in PORTn.IN where the RxD pin is located.
Thus trying to read the state of my pin before trying to read the data. I also use the "volatile int x" statement for a garunteed breakpoint to capture any non-zero value to no avail.
Has anyone had any experience with this series of chips that could either shed some light on where I can go from here or perhaps have a working example of it?
-Ryan.