I’ve started to use the rabbit core module 4200 in some applications at my work but I’m finding it very hard to find some explanation to some details in functions!
I’ve encountered a problem while researching about the WrportI function…
I understand the way it works but I would like to know where can I find the description of which macros can I use in the 1st parameter: “address of Internal I/O” and what does they mean (PxDDR, PxDR…) and what the values I send in the 3rd parameter mean, because I know they have different functions depending on the 1st parameter…
The WrPortI function writes to the internal I/O bus on the Rabbit. This is where all of the processor control/configuration registers are located. If you purchased a dev kit, you received an easy reference poster which shows most of the peripheral blocks within the Rabbit such as timers, parallel ports (processor pins), serial ports, etc. The capitalized bold mnemonic names of these ports (ie PADR for Parallel Port A Data Register, SCER for Serial Port C Extended Register) are pre-defined within Dynamic C libraries and most also have associated shadow registers declared (ie. PADRShadow, SCERShadow).
The port mnemonic is nothing more than a define that is set equal to the numeric address of the stated port. The shadow variable is an actual variable for holding the state of the port. Therefore, a WrPortI call is as follows:
WrPortI(PORT, &PORTShadow, NewValue);
Where PORT is the address of the port (or pre-defined mnemonic)
PORTShadow is the shadow variable for the port.
NewValue is the new value you are setting the port to.
Often, you will find that NewValue uses some masked portion of the PORTShadow, ORed or added to another value. This is to maintain the existing value on certain bits within the port, while changing the value of others. This is the purpose of a shadow register, to allow you to change certain bits of a port, without overwriting the value of other bits that may cause undesired effects. Understand that many internal ports have bits packed together that may control many different aspects, and it is often desirable to change one setting, while not disturbing others.