We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
another newbie question.
I have a piece of code that I am porting from PICC. In PICC, you can make reference to specific pins ("#define sclk GPIO5" for example), and in your code, you can write to sclk to change the pin output on GPOI5. This makes porting code or changing pin layout so much easier as you can simple redefine sclk to a different pin to make the code work.
ARM seems to prefer to change its pin output through IOSET / IOCLR.
To make the existing PICC code work, I would prefer to be able to define certain pins logically, and change their states by referencing their logic names.
how do you do that in ARM? Thanks in advance.
The pins on the PIC are integrated in the core, allowing direct access.
The ARM core is just a naked core. See it as a PC processor where the serial port etc are connected on PCI boards on the other side of a bus that has way lower bandwidth than the processor core.
When doing read/modify accesses to a device that are 10-20 clock cycles away, the processor core must lock up while waiting for the read access to produce any results. The set and clear registers means that you can change individual pins without needing a read - you don't need to know the old states of any pins. The actual processing of the set or clear access isn't handled by the ARM core, but out at the GPIO peripherial module.
Some later generation ARM releases have managed to move the GPIO functionality closer to the core, greatly increasing the bandwidth of port accesses. But the GPIO are still not integrated with the core, so while a 100 MIPS ARM may be able to toggle an output pin 100 million times in a second, it would not be able to do 100 million reads + writes for performing an xor of a pin.
When running a processor at 10 MIPS, it is important to have fast I/O pins. Having a processor capable of 500 MIPS reduces the need for having a 1:1 relation between core bandwidth and GPIO bandwidth.