]> rtime.felk.cvut.cz Git - fpga/virtex2/uart.git/blobdiff - software/main.c
PWM test added to the software.
[fpga/virtex2/uart.git] / software / main.c
index 44235055e74a8799ed2a92b3cdc8c3ba8782534c..586363ac34094f16cde07b1235191363554eb52d 100644 (file)
@@ -1,13 +1,16 @@
 /**
 This is a sample application for openMSP430 softcore MCU with external HW UART
 /**
 This is a sample application for openMSP430 softcore MCU with external HW UART
-peripheral <git@rtime.felk.cvut.cz:fpga/uart> and quadcount peripheral.
+periphery <git@rtime.felk.cvut.cz:fpga/uart> 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.
 
 
 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!".
 
 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.
 */
 
 Baudrate is set to 115200.
 */
 
@@ -85,6 +88,8 @@ int main(void) {
     uint32_t qcnt = qcount();
     uint32_t qcnt_new;
 
     uint32_t qcnt = qcount();
     uint32_t qcnt_new;
 
+    int sign = 1;
+
     //UBAUD = 0x04E1;                     //24.00MHz - 9600 baud
     UBAUD = 0x0067;                     //24.00MHz - 115200 baud
 
     //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;
       }
         printf("[QCount = 0x%08lX]\n", qcnt_new);
         qcnt = qcnt_new;
       }
+      
+      if (sign) {
+        if (++PWM == 0xFFFF) sign = 0;
+      } else {
+        if (--PWM == 0x0000) sign = 1;
+      }
     }
 
 }
     }
 
 }