Sample program for RPI 3 hardware PWM? - raspberry-pi

I am trying to use the RPI 3's hardware PWM pin.
Is there a simple Bash script or C program that activates and controls the PWM pin?

WiringPi has written a GPIO utility for testing against the Raspberry GPIO pins. It includes PWM functionallity. Check it out on http://wiringpi.com/the-gpio-utility/

Related

Is this PCM1860 connected ok for hardware control mode?

I connected the PCM1860 ADC in this manner. I expect data on my oscilloscope on the digital output (pin 18). I have so far only seen square wave on the clock pins but nothing on the data pin. Is this connected ok?

Can MPU6050 implement hand lift detection in low power mode?

If i want to use mpu6050 intterrupt to wake up stm32.
when i move my board,stm32 can wake up form stop mode.
i have realized the iic communication between stm32 and mpu6050.and stm32 can already enter stop mode.

STM32F0 exit from STOP on SPI receive interrupt

Am I correct in assuming that it's not possible to exit from STOP mode on SPI receive interrupt, because all the clocks are stopped?
Yes, SPI is stopped in STOP mode.
If your MCU is the SPI slave, and you can afford to lose the first packet, i.e. the master will restart if it doesn't get the right answer, then you can reconfigure the NSS pin as an EXTI activated on falling edge, it will work even in STOP mode.
You are correct, SPI receive interrupt cannot be used to wake up the controller from STOP mode.
But any EXTI Line configured in Interrupt mode can wake up the microcontroller. (Table source)
The complete EXTI line mapping can be found in the reference manual, page 176. From GPIOs are mapped to EXTI0 - EXTI15. And the remaining usable lines are the following:
EXTI line 17 is connected to the RTC Alarm event
EXTI line 18 is connected to the internal USB wakeup event
EXTI line 19 is connected to the RTC Tamper and TimeStamp events
EXTI line 20 is connected to the RTC Wakeup event (available only on STM32F070xB and STM32F030xC devices)
EXTI line 23 is connected to the internal I2C1 wakeup event
What you can do is configuring an external interrupt on the GPIO pin of the corresponding SPI line which will wake up the controller. After that the proper SPI RX interrupt can be used. Note that you will lose the early data on the SPI as you will only have a GPIO interrupt and the SPI peripheral will be stopped until wake up.

Scratch + GPIO + Adafruit MotorHAT

I have a Raspberry PI2 with Adafruit MotorHAT, and two stepper motors attached to the hat. I have installed the Cymplecy GPIO7 on my Raspberry Pi 2, and I tried to control the stepper motors with it, but I cannot. I set the AddOn variable to MotorHAT, and send broadcast message "motor1speed20" but nothing happens.
Does anybody know anything about how to control stepper motors using scratch in such an environment like this? Does GPIO addon supports this adafruit motorhat?

Raspberry pi transistor

I wanted to know if anyone knows if I can use a transistor as an on/off switch that is controlled by a GPIO pin? I am sorry that I have to right this but this needs to be the right length so that I can post it.
Yes
Like below (not the only way).
GPIO high = switch on
GPIO low = switch off