2 see README.txt for details.
4 original by: chris <cliechti@gmx.net>
6 modified by: Vladimir Burian <buriavl2@fel.cvut.cz>
17 inline uint32_t qcount() {
21 result |= ((uint32_t)QCNTH << 16);
27 Handling of QuadCounter IRQ
29 interrupt(QCNT_VECTOR) qcount_isr() {
30 printf("[QCount = 0x%08lX]\n", qcount() >> 2);
37 void delay(unsigned int d) {
45 Main function with init an an endless loop that is synced with the
46 interrupts trough the lowpower mode.
54 WDTCTL = WDTCTL_INIT; //Init watchdog timer
56 P1OUT = P1OUT_INIT; //Init output data of port1
57 P1SEL = P1SEL_INIT; //Select port or module -function on port1
58 P1DIR = P1DIR_INIT; //Init port direction register of port1
59 P1IES = P1IES_INIT; //init port interrupts
62 P2OUT = P2OUT_INIT; //Init output data of port2
63 P2SEL = P2SEL_INIT; //Select port or module -function on port2
64 P2DIR = P2DIR_INIT; //Init port direction register of port2
65 P2IES = P2IES_INIT; //init port interrupts
69 P3OUT = 0xff; //light LED during init
70 delay(65535); //Wait for watch crystal startup
72 // fllInit(); //Init FLL to desired frequency using the 32k768 cystal as reference.
73 P3OUT = 0x00; //switch off LED
75 TACTL = TACTL_AFTER_FLL; //setup timer (still stopped)
76 CCTL0 = CCIE|CAP|CM_2|CCIS_1|SCS; //select P2.2 with UART signal
79 TACTL |= MC1; //start timer
81 eint(); //enable interrupts
83 printf("\r\n====== openMSP430 in action ======\r\n"); //say hello
84 printf("\r\nSimple Line Editor Ready\r\n"); //say hello
86 printf("\n[QCount = 0x%08lX]\n", qcount());
88 while (1) { //main loop, never ends...
89 printf("> "); //show prompt
91 while (reading) { //loop and read characters
92 LPM0; //sync, wakeup by irq
94 led++; // Some lighting...
98 P3OUT = (0x01 << led);
104 printf("\r\n"); //finish line
105 buf[pos++] = 0; //to use printf...
106 printf(":%s\r\n", buf);
107 reading = 0; //exit read loop
108 pos = 0; //reset buffer
112 if (pos > 0) { //is there a char to delete?
113 pos--; //remove it in buffer
114 putchar('\b'); //go back
115 putchar(' '); //erase on screen
116 putchar('\b'); //go back
121 //only store characters if buffer has space
122 if (pos < sizeof(buf)) {
123 putchar(rxdata); //echo
124 buf[pos++] = rxdata; //store