Have Raspberry Pi 3 native PMW outs?
Have Raspberry Pi 3 native PMW outs?
Yes. One of them is used to make the "analog out" output. Look for the "BCM2835 arm peripherals" datasheet. It should provide you with the right data. (even though the raspberry pi 3 has an BCM2837 processor, the peripherals are compatible (bugs included) wth the 2835).
I assume you mean PWM.
Then yes and it's quite easy to add more using either I2C, SPI or GPIO.
If you hunt around you'll be able to find Linux drivers for PWM and the RPI.
I presume you mean hardware PWM (as software ones, use overheads and so are wasteful and take up precious computing time) - yes, it does have hardware PWM.... however:
There is an excellent library, bcm2835 lib, which includes the hardware PWM init section and this works fine on all RPIs except RPI3. If you look at he Raspberry Pi Forums you will see that many are finding that the hardware PWM is not working on the RPI3, me included.
You will read the usual comments from people who have never actually tested saying it must be hardware, but I and others have tested it on load of new sets of hardware. When using the RPI2 the hardware PWM works everytime.
For example, see this link (which is simply 1 of many)
pi 3 - Using PWM on raspberry pi 3 vs pi 2 with bcm2835 library - Raspberry Pi Stack Exchange
Some users find that running at sudo level fixes their problem, with others it makes no difference.
I does appear that there is some oddity with the hardware PWM on just the RPI3 version and so if anyone has actually got it to work (not software PWM) please share.
Steve
ndtsteve schrieb:
[...] There is an excellent library, bcm2835 lib, which includes the hardware PWM init section and this works fine on all RPIs except RPI3. If you look at he Raspberry Pi Forums you will see that many are finding that the hardware PWM is not working on the RPI3, me included.
You will read the usual comments from people who have never actually tested saying it must be hardware, but I and others have tested it on load of new sets of hardware. When using the RPI2 the hardware PWM works everytime.[...]
Steve
@ndtsteve If you say it works using the RPI2 do you mean the "old" Raspberry Pi 2 Model B V1.1 with the BCM2836 or the new Raspberry Pi 2 Model B V1.2 with the BCM2837 processor?
@Peter
Yes, that library works with ALL RPI2 models, version 1.1 with BCM2836 and version 1.2 with BCM2837 - this is the link to that library for you to see the instructions in the event you have not got them:
bcm2835: C library for Broadcom BCM 2835 as used in Raspberry Pi
The lib is currently V1.51. All works well except the HARDWARE PWM for some reason with many users, even when starting with a fresh new RPI3, newly installed Raspian and lib, with nothing else loaded or added and running the test program at sudo level.
Out of interest, here is another link where the user gave up and bought a separate hardware PWM module:
https://groups.google.com/forum/m/#!topic/bcm2835/mZjLtVmlKV8
You say it doesn't work for rpi3.
#define BCM2835_PERI_BASE 0x20000000
I had a quick look at the source code, and found your bug. The peripherals on RPI3 do NOT start at that address.
My time is limited today, but even if you're just starting with pi and programming, downloading that library, compiling it, testing it on a RPI 2, then googling for what the correct address is on RPI3, and simply changing that define and testing on RPI3 would be a fun excercise. It could just work....
Of course the "neat" solution would be to detect RPI3 processor and automatically do the right thing, but as a proof of concept the "change the define" should work.
The bcm2835 lib DOES set the BCM2835_PERI_BASE 0x30000000 and not to the older 0x20000000
It detects which version of RPI it is and auto sets the peripheral base to suit, which is used for the SPI, the timer ticks, interrupts and so on.
I have used the lib from day 1 on many RPI projects and it is very good at setting the addresses to match the version of RPI. If you study the bcm2835 header it says this and uses offsets get to the correct base:
/*! Physical addresses for various peripheral register sets
Base Physical Address of the BCM 2835 peripheral registers
Note this is different for the RPi2 BCM2836, where this is derived from /proc/device-tree/soc/ranges
If /proc/device-tree/soc/ranges exists on a RPi 1 OS, it would be expected to contain the
following numbers:
*/
/*! On RPi2 with BCM2836, and all recent OSs, the base of the peripherals is read from a /proc file */
#define BMC2835_RPI2_DT_FILENAME "/proc/device-tree/soc/ranges"
/*! Offset into BMC2835_RPI2_DT_FILENAME for the peripherals base address */
#define BMC2835_RPI2_DT_PERI_BASE_ADDRESS_OFFSET 4
/*! Offset into BMC2835_RPI2_DT_FILENAME for the peripherals size address */
#define BMC2835_RPI2_DT_PERI_SIZE_OFFSET 8
/*! Peripherals block base address on RPi 1 */
#define BCM2835_PERI_BASE 0x20000000
/*! Size of the peripherals block on RPi 1 */
#define BCM2835_PERI_SIZE 0x01000000
/*! Offsets for the bases of various peripherals within the peripherals block
/ Base Address of the System Timer registers
*/
#define BCM2835_ST_BASE 0x3000
/*! Base Address of the Pads registers */
#define BCM2835_GPIO_PADS 0x100000
/*! Base Address of the Clock/timer registers */
#define BCM2835_CLOCK_BASE 0x101000
/*! Base Address of the GPIO registers */
#define BCM2835_GPIO_BASE 0x200000
/*! Base Address of the SPI0 registers */
#define BCM2835_SPI0_BASE 0x204000
/*! Base Address of the BSC0 registers */
#define BCM2835_BSC0_BASE 0x205000
/*! Base Address of the PWM registers */
#define BCM2835_GPIO_PWM 0x20C000
/*! Base Address of the BSC1 registers */
#define BCM2835_BSC1_BASE 0x804000
It then goes and adds
/*! Physical address and size of the peripherals block
May be overridden on RPi2
*/
extern uint32_t *bcm2835_peripherals_base;
/*! Size of the peripherals block to be mapped */
extern uint32_t bcm2835_peripherals_size;
/*! Virtual memory address of the mapped peripherals block */
extern uint32_t *bcm2835_peripherals;
However, if just changing the definition, which was for the RPI1 series and if that works, then good. Please let me know.
Thanks
I stand corrected. I didn't look deep enough. Sorry.
IF the peri-base is 0x30000000 as you say, THEN it is wrong, because it uses 0x3f000000. But I suspect that 0x3f.. is the correct one.