]> rtime.felk.cvut.cz Git - fpga/virtex2/uart.git/commitdiff
PWM test added to the software.
authorVladimir Burian <buriavl2@fel.cvut.cz>
Sat, 12 Feb 2011 23:17:08 +0000 (00:17 +0100)
committerVladimir Burian <buriavl2@fel.cvut.cz>
Sun, 13 Feb 2011 12:47:21 +0000 (13:47 +0100)
software/hardware.h
software/main.c

index 9255487742347937028781b7d312328b1893da6f..446e40bb1661a9c36ead44cd963a8e9f805ce4fb 100644 (file)
@@ -31,4 +31,8 @@ sfrb(USTAT, USTAT_);
 sfrb(UIE, UIE_);
 
 
+//PWM output
+#define PWM_              0x0160
+sfrw(PWM, PWM_);
+
 #endif
index 44235055e74a8799ed2a92b3cdc8c3ba8782534c..586363ac34094f16cde07b1235191363554eb52d 100644 (file)
@@ -1,13 +1,16 @@
 /**
 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.
 
-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;
+      }
     }
 
 }