peripheral <git@rtime.felk.cvut.cz:fpga/uart> and quadcount peripheral.
First of all "Hello world" is printed and then application works like echo and
-also prints quadrature count whenever its value is changed (only whole turns
-are reported).
+also prints quadrature count whenever its value is changed.
+
+AB error of quadrature counter peripheral is handled by irq routine which prints
+message "IRQ: QCounter AB error!".
Baudrate is set to 115200.
*/
Handling of QuadCounter IRQ
*/
interrupt(QCNT_VECTOR) qcount_isr() {
- printf("[QCount = 0x%08lX]\n", qcount() >> 2);
+ puts("IRQ: QCounter AB error!");
+ qcount();
}
Main function with init and an endless loop.
*/
int main(void) {
+ uint32_t qcnt = qcount();
+ uint32_t qcnt_new;
//UBAUD = 0x04E1; //24.00MHz - 9600 baud
UBAUD = 0x0067; //24.00MHz - 115200 baud
puts("Hello world\n");
- for (;;) {
- putchar(getchar());
+ for (;;) {
+ while (!isRxEmpty()) {
+ putchar(URX);
+ }
+
+ qcnt_new = qcount();
+ if (qcnt != qcnt_new) {
+ printf("[QCount = 0x%08lX]\n", qcnt_new);
+ qcnt = qcnt_new;
+ }
}
}