• CountT5A1Poke.js
    Program that looks at timer registers to test timer 5 in
    External clock source mode 1 see page 377,378 of RM0008
    Reference manual

    Sets up a PWM on Pin B0, connect to pin A1 channel 2 of timer 5.

    analogWrite(B0,0.5,{ freq : 1000 });
    
    //setup pins A0, A1, A2, A3
    A0.mode('input');
    A1.mode('input');
    A2.mode('input');
    A3.mode('input');
    
    //timer 5 clock
    var RCCbase=0x40021000;
    var APB1ENR=RCCbase+0x1c;
    var APB1RST=RCCbase+0x10;
    var APB2ENR=RCCbase+0x18;
    
    //turn on timer 5 clock
     poke8(APB1ENR,(peek8(APB1ENR)&0xf7)|0x08­);
    
    //reset timer 5
     poke8(APB1RST,(peek8(APB1RST)&0xf7)|0x08­);
     poke8(APB1RST,(peek8(APB1RST)^0x08));
    
    //disable timer 5
      poke32(TIM5+CR1,0x80);
    
    //setup timer 5
    poke16(TIM5+CCMR1,0x0100);
    poke16(TIM5+CCER,0x0000); //0;
    poke16(TIM5+SMCR,0x0067);//0x0067);
    //Preload timer
    poke32(TIM5+EGR,1);
    //Enable timer 5
    poke32(TIM5+CR1,0x81); //10Hz
    
    //Display timers
    for(var i=0; i in timers;i++){
     if(isTimerEnabled(timers[i])) 
      showTimer(timers[i].t,16,i);
    }//next i
    
    console.log("Display Count");
    for(var i=0;i<1000;i++)
      console.log("CNT="+peek32(TIM5+CNT));
    
    

    Try changing the frequency of the PWM on pin B0.


    1 Attachment

About