From: Vladimir Burian Date: Sat, 12 Feb 2011 23:17:08 +0000 (+0100) Subject: PWM test added to the software. X-Git-Url: https://rtime.felk.cvut.cz/gitweb/fpga/virtex2/uart.git/commitdiff_plain/d90e54632ccf2cc286e1c33c802211e7f7ebdc08?ds=sidebyside PWM test added to the software. --- diff --git a/software/hardware.h b/software/hardware.h index 9255487..446e40b 100644 --- a/software/hardware.h +++ b/software/hardware.h @@ -31,4 +31,8 @@ sfrb(USTAT, USTAT_); sfrb(UIE, UIE_); +//PWM output +#define PWM_ 0x0160 +sfrw(PWM, PWM_); + #endif diff --git a/software/main.c b/software/main.c index 4423505..586363a 100644 --- a/software/main.c +++ b/software/main.c @@ -1,13 +1,16 @@ /** This is a sample application for openMSP430 softcore MCU with external HW UART -peripheral and quadcount peripheral. +periphery and quadcount and pwm periphery. First of all "Hello world" is printed and then application works like echo and also prints quadrature count whenever its value is changed. -AB error of quadrature counter peripheral is handled by irq routine which prints +AB error of quadrature counter periphery is handled by irq routine which prints message "IRQ: QCounter AB error!". +In endless main loop, when nothing else is doing, triangle singnal is being +generated by the PWM periphery. + Baudrate is set to 115200. */ @@ -85,6 +88,8 @@ int main(void) { uint32_t qcnt = qcount(); uint32_t qcnt_new; + int sign = 1; + //UBAUD = 0x04E1; //24.00MHz - 9600 baud UBAUD = 0x0067; //24.00MHz - 115200 baud @@ -103,6 +108,12 @@ int main(void) { printf("[QCount = 0x%08lX]\n", qcnt_new); qcnt = qcnt_new; } + + if (sign) { + if (++PWM == 0xFFFF) sign = 0; + } else { + if (--PWM == 0x0000) sign = 1; + } } }