Make-Magazine / PirateRadio

Raspberry Pi Automated FM Radio Script
458 stars 156 forks source link

Change what GPIO pin is used for output #20

Closed sburning closed 9 years ago

sburning commented 9 years ago

Can someone point me to where in the C file the gpio pin is configured as 4? I would like to set this up to use a different pin, but am lost. It would be great if this was a configuration item.

cydactyl commented 9 years ago

If you're using the Raspberry Pi Model B, GPIO pin 4 is the only accessible pin that can be used from what I've seen on the wiki.

I'm not exactly sure why, and I don't know if there is an option on the Raspberry Pi B+, however the links below may help you.

http://elinux.org/RPi_BCM2835_GPIOs

http://elinux.org/RPi_Low-level_peripherals#General_Purpose_Input.2FOutput_.28GPIO.29

sburning commented 9 years ago

Thanks for the information. I am using the B+. I will try to get it working on Pin 4 but It also cant hurt to try a different pin, I just don't see where in the C code where it specifies Pin 4, but no worries.

dmorawetz commented 9 years ago

I think the pin is set at line 119. It sets the 14th bit of gpfsel0 (which is a gpio register) to 1.

zerotri commented 9 years ago

I apologize for the lack of participation on this project as of late. My understanding is that the software relies on the General Purpose Clock functionality of Pin 4, which allows you to specify the clock at which the pin cycles. Doing this on another pin that doesn't have GPCLK functionality is much more processor intensive and is susceptible to odd latency issues caused by the operating system switching processes.

The advantage to the GPCLK pin is that you can specify the rate at which is cycles and then physical hardware in the chip will control the cycling of the pin at that rate until it is told otherwise. The pi could be stuck in a heavily processor intensive task and the pin would still cycle at a constant rate.

The Pi A and B only expose a single GPCLK enabled pin. The B+ however seems to expose several others. These are: GPIO 5 - J8-29 (CAM_CLK is on this pin, so that is likely to disable camera functionality) GPIO 6 - J8-31 (LAN_RUN is on this pin, so this will likely disable ethernet functionality on A/B/B+) GPIO 20 - J8-38 ( I believe this is used by the PCM output though, so you'd likely need to disable that) GPIO 31 - J8-40 ( I believe this is used by the PCM output though, so you'd likely need to disable that)

As for the software work necessary to make these changes possible, I've not looked into the C code lately. It should be fairly minimal however. Just keep in mind you will be giving up other functionality for this.

sburning commented 9 years ago

Thanks for the explanation on this everyone.