element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Have Raspberry Pi 3 native PMW outs?
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 8 replies
  • Subscribers 677 subscribers
  • Views 1641 views
  • Users 0 members are here
  • raspberry_pi
Related

Have Raspberry Pi 3 native PMW outs?

massimiliano.pilosio@libero.it
massimiliano.pilosio@libero.it over 8 years ago

Have Raspberry Pi 3 native PMW outs?

  • Sign in to reply
  • Cancel
Parents
  • ndtsteve
    0 ndtsteve over 8 years ago

    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

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • rew
    0 rew over 8 years ago in reply to ndtsteve

    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.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • ndtsteve
    0 ndtsteve over 8 years ago in reply to rew

    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

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • rew
    0 rew over 8 years ago in reply to ndtsteve

    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.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • rew
    0 rew over 8 years ago in reply to ndtsteve

    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.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube