Firstly, I have a Pi3 and I can see only 40 GPIO pins similar to this Pi2 GPIO diagram https://cdn.sparkfun.com/assets/learn_t ... pinout.jpg. But page 89 on the BCM2835 Peripherals document says "There are 54 general-purpose I/O (GPIO) lines split into two banks". Did Pi1 have 54 pins and they reduced it to 40 in Pi2/3? Or am I misunderstanding something?
Second thing. I connected Pi3 to my laptop using USB to TTL cable and successfully ran this program: https://github.com/bztsrc/raspi3-tutori ... rt0/uart.c.
r|=(4<<12)|(4<<15); // alt0
I understood that above Line 63 in the code selects ALT0 function for pin 14/15. As per page 102 in BCM2835 Peripherals document ALT0 is TXD0/RXD0 (which I guess means transmitter and receiver for serial comms). I also noticed that ALT5 for the pins has the same function. So I modified the code to use ALT5 as below.
r|=(2<<12)|(2<<15); // alt5
I tested is successfully on qemu for raspi3. Next I tried selecting the other ALT functions for the pins and the program still kept working fine in qemu! Either the qemu simulation is not correct or I have misunderstood something. I want to try it on a real Pi3 to verify if qemu is at fault but I am afraid to try it. Is it safe if I make mistakes in my program or is there a possibility to damage Pi3 or my laptop connected via USB? I am a software-only guy and don't understand much about electronics so this worry.
Also I can see pin 32/33 (ALT3 and ALT5), pin 36/37 (ALT2), pin 40/41 (ALT5) say TXD and RXD. So If I connect my UART cable to these pins instead of 14/15 and modify my code to select these pins and appropriate alt functions will the communication work?
Lastly, I just pull out the USB from my laptop as I cannot see any eject option in Ubuntu. Is this safe or is there anything I need to do before I pull out the USB side of the cable?