Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. #include "msp430x14x.h"
  2. #define B1 BIT4&P4IN //B1 - P4.4
  3. #define STATUS_LED_ON P2OUT &= ~BIT1 //STATUS_LED - P2.1
  4. #define STATUS_LED_OFF P2OUT |= BIT1 //STATUS_LED - P2.1
  5.  
  6. void InitPorts(void)
  7. {
  8. P1SEL = 0; //
  9. P1OUT = 0; //
  10. P1DIR = BIT5 | BIT6; //enable only Relay outputs
  11.  
  12. P2SEL = 0;
  13. P2OUT = 0;
  14. P2DIR = ~BIT0; //only P2.0 is input
  15.  
  16. P3SEL |= BIT4 | BIT5; //enable UART0
  17. P3DIR |= BIT4; //enable TXD0 as output
  18. P3DIR &= ~BIT5; //enable RXD0 as input
  19.  
  20. P4SEL = 0;
  21. P4OUT = 0;
  22. P4DIR = BIT2 | BIT3; //only buzzer pins are outputs
  23.  
  24. P6SEL = 0x80;
  25. P6OUT = 0;
  26. P6DIR = 0x00; // all output
  27. }
  28.  
  29.  
  30.  
  31. /*//1...
  32. int main( void )
  33. {
  34.  
  35. InitPorts();
  36.  
  37.  
  38. WDTCTL = WDTPW + WDTTMSEL;
  39. IE1=WDTIFG;
  40. P1DIR=BIT0+BIT6;
  41. P1OUT=BIT0;
  42. _EINT(); //enable interupts
  43. BCSCTL2=DIVS_2; //clock and interval
  44. while(1){}
  45.  
  46. }
  47.  
  48. */
  49. //2...
  50. int main( void )
  51. {
  52. InitPorts();
  53.  
  54. WDTCTL = WDTPW + WDTHOLD;
  55. IE1=WDTIFG;
  56. P1DIR=BIT0+BIT6;
  57. P1OUT=BIT0;
  58. _EINT(); //enable interupts
  59. BCSCTL2=DIVS_3;
  60.  
  61. while(1)
  62. {
  63.  
  64. if((B1) == 0){
  65.  
  66. WDTCTL = WDTPW + WDTTMSEL;
  67.  
  68.  
  69. }
  70. }
  71.  
  72.  
  73. }
  74.  
  75.  
  76. #pragma vector=WDT_VECTOR
  77. __interrupt void wdttimer(void)
  78. {
  79.  
  80. P1OUT^=BIT0+BIT6;
  81. IFG1&=~WDTIFG; //czyszczenie flagi timera
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement