• Sun 2020.03.15

    Eight hours later . . . .

    Before I started messing with the channel within enable, ll.ppiEnable( 0, rtc.eTick, tog.tOut ); the setWatch using PPI on channel 0 worked one and only one time!! I've attempted to reproduce, and the only thing left off the list is to reboot the PC. Although an unlikely solution, will try over the next few days.



    Found this note:
    ** Real time counter
    You should only set on ch2 as 0 and 1 are used by Espruino/Bluetooth
    This function intentionally doesn't set state itself to allow you
    to still query RTC0/1 without modifying them.

    http://www.espruino.com/modules/NRF52LL.­js



    So did a complete code re-write, carefully inserting working snippets and using channel 3 for the enable and thought I was making progress. Now I've found a repeatable/reproduceable condition using the PPI counter.

    The prescaler calculation needs a review. Any value greater than 2047 (0x07FF) yielding a frequency slower than 16Hz or 62.5msec always outputs a 5Hz or 200msec output wave.

    // Toggle LED
    function tled() {
    
      // Is needed to setup PPI for some reason  
      poke32( rtc.tStop, 1 );
    
    
    // These work - but is positive pulse width and not freq - so is one half of freq
    
    //  poke32( rtc.prescaler, 64 ); // 32kHz / 64 = 500 Hz - 2000 usec
    //actual 4msec = 250Hz
    
    //  poke32( rtc.prescaler, 162 ); // 32kHz / 162 = 200 Hz - 5000 usec
    //actual 9msec = 111Hz
    
    //  poke32( rtc.prescaler, 326 ); // 32kHz / 326 = 100 Hz - 10000 usec
    //actual 18msec = 55Hz
    
    //  poke32( rtc.prescaler, 2047 ); // 32kHz / 2047 = 16 Hz - 62.5 msec
    //actual 120msec = 8.3Hz
    
    
    
    
      
    
    //These are all the same - and in error
    //  poke32( rtc.prescaler, 4095 ); // 32kHz / 4095 = 8 Hz - 125 msec
    //actual 200msec = 5Hz
    
    //  poke32( rtc.prescaler, 8191 ); // 32kHz / 8191 = 4 Hz - 250 msec
    //  poke32( rtc.prescaler, 16383 ); // 32kHz / 16383 = 2 Hz - 500 msec
    //  poke32( rtc.prescaler, 32767 ); // 32kHz / 32767 = 1 Hz - 1000 msec
    
    
    
    // No prescaler test
      poke32( rtc.prescaler, 0 ); // no prescaler, 32 kHz
      //actual 60usec = 16,667Hz
    
    // Just realized that the counter clock is putting out very narrow 
    // edges <1usec which is rtc.eTick
    // Our scope is monitoring pin D22 with the alternating state of 
    // the toggle register, so each edge
    // changes state, thereby giving us a frequency that is half at 
    // the output pin.
    
    
      rtc.enableEvent( "eTick" );
    
      poke32( rtc.tStart, 1 ); // start RTC
    
    // Use a PPI to trigger the toggle event
    //ll.ppiEnable(0, rtc.eTick, tog.tOut);
    
    // http://www.espruino.com/modules/NRF52LL.­js
    // ** Real time counter
    //  You should only set on ch2 as 0 and 1 are used by Espruino/Bluetooth
    //  This function intentionally doesn't set state itself to allow you
    //  to still query RTC0/1 without modifying them.
    
    
      ll.ppiEnable( 3, rtc.eTick, tog.tOut );
    }
    



    While this will need to be corrected, at the moment I still don't have a means to reflash the MDBT42Q, although I expect to pick up a tablet once a suitable one can be sourced. At least a week out as of today.


    Firing up the STM32 WiFi to compare techniques . . . .

    https://www.espruino.com/STM32+Periphera­ls

About

Avatar for Robin @Robin started