Guru Meditation Error of type LoadProhibited occurred on core.



  • I'm running a basic all reading a distance from an HC-SR04 ultrasonic sensor, & after a shortish(irregular) amount of time the board crashes with the following message:

    Guru Meditation Error of type Load Prohibited occurred on core  0. Exception was unhandled.                              
    Register dump:                                                                                                          
    PC      : 0x400869c6  PS      : 0x00060037  A0      : 0x80085b58  A1      : 0x3ff81c50                                  
    A2      : 0x3ff81cac  A3      : 0x3ff81c70  A4      : 0x00000020  A5      : 0x3ffc397c                                  
    A6      : 0x00000005  A7      : 0x3ffae010  A8      : 0xe67ec000  A9      : 0x3ffb6db8                                  
    A10     : 0x3ff81cac  A11     : 0x3ffc3a88  A12     : 0x3ffb6db8  A13     : 0x3ffae020                                  
    A14     : 0x3ffae040  A15     : 0x3ffae6c0  SAR     : 0x0000001f  EXCCAUSE: 0x0000001c                                  
    EXCVADDR: 0xe67ec004  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0x00000000                                  
                                                                                                                            
    Backtrace: 0x400869c6:0x3ff81c50   
    

    My code is based on this: https://github.com/mithru/MicroPython-Examples/blob/master/08.Sensors/HC-SR04/ultrasonic.py

    Anyone have any idea what this means & what can be done about it?



  • @tobru From memory I think it was a 10k resister - check the spec sheet for the HC-SR04. I probably just attached it straight onto the expansion board, maybe via a breadboard - I can't remember sorry.



  • @tobz Thanks a lot for sharing the code. How did you connect the sensor to the board? You mentioned something about a resistor you had to use?



  • @RobTuDelft Here's the code I was using for the HC-SR04.
    I hope it makes sense & works for you.

    import machine
    import time
    import math
    from machine import Timer
    
    class Ultrasonic:
        def __init__(self, name, trigPin, echoPin, delay = 60):
    
            self.name = name
            self.triggerPin = trigPin
            self.echoPin = echoPin
            self.delay = delay
    
            self.last_distance = 0
    
            # Init trigger pin (out)
            self.trigger = machine.Pin(self.triggerPin)
            self.trigger.init(machine.Pin.OUT, None)
            self.trigger.value(False)
    
            # Init echo pin (in)
            self.echo = machine.Pin(self.echoPin)
            self.echo.init(machine.Pin.IN)
    
        def distance_in_inches(self):
            return (self.distance_in_cm() * 0.3937)
    
        def distance_in_cm(self):
            start = 0
            end = 0
    
            # Create a microseconds counter.
            micros = Timer.Chrono()
            micros.reset()
            micros.start()
    
            # Send a 10us pulse.
            self.trigger.value(True)
            Timer.sleep_us(10)
            self.trigger.value(False)
    
            # Wait 'till whe pulse starts.
            while self.echo.value() == 0:
                start = micros.read_us()
    
            # Wait 'till the pulse is gone.
            while self.echo.value() == 1:
                end = micros.read_us()
    
            # Deinit the microseconds counter
            micros.stop()
    
            # Calc the duration of the recieved pulse, divide the result by
            # 2 (round-trip) and divide it by 29 (the speed of sound is
            # 340 m/s and that is 29 us/cm).
            dist_in_cm = ((end - start) / 2) / 29
    
            return dist_in_cm
    
        def start(self, threshold, callback):
            print('Start reading Ultrasonic Sensor')
            while True:
                # get the current distance
                distance = self.distance_in_cm()
    
                # if the distance between this reading and the previous one
                # and the difference is greater than the threshold then
                # run the callback method
                if (math.fabs(self.last_distance - distance) > threshold):
                    print("%s value: %s -> %s at %s" % (self.name, self.last_distance, distance, time.time()))
    
                    if callback(self.name, distance) is True:
                        # set this readding as the previous reading for next run
                        self.last_distance = distance
    
                else:
                    print("%s value: %s <-> %s at %s" % (self.name, self.last_distance, distance, time.time()))
    
                time.sleep(self.delay)
    

    useage:

    // init sensor, reading every 60 seconds
    sensor = Ultrasonic('some-name', triggerPin, echoPin, 60)
    sensor.start(changeThreshold, callbackMethod)
    


  • @RobTuDelft sorry - I've been head down in work - will hopefully get some time later this week & post my code if you're still interested in it.



  • @tobz That's nice, could you share your code perhaps? Got one of these sensors coming in soon and would help to have a starting point.



  • @RobTuDelft yeah the sensor works fine (once I worked out you need a resistor in the circuit - derp). The crash appears to be caused by the urequest library (see https://forum.pycom.io/topic/1061/https-post-using-urequests-py-and-guru-mediation-error).



  • @tobz Did you manage to get the HC-SR04 working after all?



  • @bucknall Cool. I'll follow along with that thread & hopefully that IS my issue and it gets resolved :)



  • @tobz Ah ok, you are using the urequests library? We're looking into this.

    Thanks!



  • I think my issue might actaully be related to this post: https://forum.pycom.io/topic/1061/https-post-using-urequests-py-and-guru-mediation-error

    the urequest class and nothing to do with the ultrasonic sensor.



  • Please be aware that there are also a number of difference between the pyboard and the Pycom devices namely that Pycom doesn't use the pyb library and that a number of the standard classes/methods are different.



  • @tobz Can you please list where in your code that this error occurs?



Pycom on Twitter