PWM pin test using Servo motor

I have here a python code that tests PWM pin on my rock 4c+ after installing libmraa.

import mraa
import time

SERVO_PIN = 11 # GPIO pin number connected to the servo
MIN_PULSE = 544 # Minimum pulse width (in microseconds) for the servo
MAX_PULSE = 2400 # Maximum pulse width (in microseconds) for the servo
FREQUENCY = 50 # Servo motor frequency (in Hz)

def map_value(value, in_min, in_max, out_min, out_max):
return (value - in_min) * (out_max - out_min) / (in_max - in_min) + out_min

def main():
pwm = mraa.Pwm(SERVO_PIN)
pwm.period_us(1000000 // FREQUENCY) # Set the PWM period in microseconds
pwm.enable(True)

while True:
    for angle in range(0, 180, 5):
        pulse = int(map_value(angle, 0, 180, MIN_PULSE, MAX_PULSE))
        pwm.pulsewidth_us(pulse)
        time.sleep(0.02)

    for angle in range(180, 0, -5):
        pulse = int(map_value(angle, 0, 180, MIN_PULSE, MAX_PULSE))
        pwm.pulsewidth_us(pulse)
        time.sleep(0.02)

if name == “main”:
main()

Here’s the error:

ValueError: Error Initialising PWM on pin
mraa.py, line 483

I wired my servo motor correctly. The error is referenced at the mraa library where I think it is all about the communication with the board. Can anyone help me solve this issue? Thanks