Hi all,

How to produce 40khz square wave on the pin that SCL_CLK?

I have overwritten the TACCR0 to make an MSP430 counter overflow interrupt, int 
the event ,by using the function that port33.setHigh or setLow to produce the 
square wave. If the TACCR0 is large ,the square wave is good but lager than the 
frequency than what I want ,If the TACCR0 is small, the port output nothing! 
Why , and How to do about it to produce square wave whose frequency is 40KHz? 
My code is that :

======================================================================

module BlinkM {

  provides {

    interface StdControl;

  }

  uses {

    interface Timer;

    interface Leds;

    interface MSP430GeneralIO as Port33;

    interface MSP430Timer as TimerA;

    interface Counter<TMicro,uint16_t> as CounterMicro;

  }

}

implementation {

       bool state=FALSE;

       int i;

  command result_t StdControl.init() {

    call Leds.init(); 

    call Port33.setLow();

WDTCTL=WDTPW+WDTHOLD;

        TACTL=0x0216;

    TACCR0=25;

    TACCTL0=CCIE;

    return SUCCESS;

  }

  command result_t StdControl.start() {

      call Timer.start(TIMER_REPEAT,100);

      return SUCCESS;

  }

 

  command result_t StdControl.stop() {

     return SUCCESS;

  }

  event result_t Timer.fired()

  {

  return SUCCESS;

  }

  async event void CounterMicro.overflow(){

        state=!state;

    if(state)

      call Port33.setHigh(); 

    else

      call Port33.setLow();

  }

  async event void TimerA.overflow(){

  }

}

 

Thanks.

 
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to