About the red(ACT) led control
geniuschen902074 opened this issue · 3 comments
Hi James:
I'm newbie to RPi bare metal programming, and now using a RPi 2 model B to self training
I'm currently digging in your port of FreeRTOS to RPi (this repo)
But very confused by how the code is written to setup the gpio and its function to control the led
Because I look up the peripheral manual and the internet all the way but can't find where it's documented
I noticed that the on-board led is internal, so maybe this seems normal?
Maybe I should consult the Raspbian source code as a reference?
If not, may I ask how your code is written? That is, how you know that you can blink the led as you wish by writing these code?
Thank you very much at least for reading my question!
Sincerely,
Y.C. Chen
Hi Mr. Chen,
this repo is written for RPi1.
The first important difference between RPi1 and RPi2 is the peripheral starting address, how you can read form https://www.raspberrypi.org/documentation/hardware/raspberrypi/peripheral_addresses.md:
"...This is 0x20000000 on the Pi Zero, Pi Zero W, and the first generation of the Raspberry Pi and Compute Module, and 0x3f000000 on the Pi 2, Pi 3 and Compute Module 3."
That mean you have to find in the code all address that begin with 0x20... and commute to 0x3f...,
but pay attention on what is to change and not...
Then another difference is the GPIO assigned to Activity Led, on RPi1 is GPIO 16 on RPi2 is GPIO 47.
I hope you can run the demo with this indication. Otherwise ask again...
Best regards.
Francesco
Hi, Francesco:
THANKS for your generous help!
Though I mentioned the usage of pi2B, this is actually not what I'm stuck, but something independent to that
That is, for instant, this function:
https://github.com/jameswalmsley/RaspberryPi-FreeRTOS/blob/master/Demo/Drivers/gpio.c#L105
After reading the manual, I can tell that this function first locates a GPIO, then selects one of its alternative functions
Then the main function can manipulate the Activity Led, like SetGpio(), after selecting function 1, regarding to GPIO16
My confusion is that, how the person writing this code know that, he should locate GPIO16 but not any other GPIO? How did he know that he should select function 1?
I've looked up GPIO16 in the manual, but been unable to figure out why its function 1(in manual section 6.2 reads "SD8 Secondary mem. data bus Secondary Memory Interface") has to do with the Activity Led...
My logic is that, for this case, I should be able to figure those question above, or at least find a source telling me that "you do this to achieve that..." etc and this is why I'm bothering you like this... hope you can forgive me for this
So, just wondering if you have any knowledge or understanding about this issue?
Maybe I'm so newbie that having this kind of confusion? May I sum my issue to this sentence: "why can the code work?"
Thanks Francesco AGAIN!!
Sincerely
Chen
Hi Chen,
On page 92 (on manual that you cited) you find how to Select the Function for every GPIO (000 = input, 001 = output, ...).
In this case to manage the Activity Led, it can be set as output, nothing alternate function, only output.
Then the Activity Led is connected to the pin of GPIO 47, i find this information in the official forum,
cause the schematic are so reduced that Act Led there isn'i in it.
Don't worry, the problem is the poor documentation, but in the other side we are lucky because there is
a strong community that share information and help each other.
Don't hesitate to ask if you need more detailed explication.
Best regards.
Francesco