??? 11/30/06 15:59 Read: times |
#128758 - ALLOCATE_EXTERN fixes PORTECFG address Responding to: ???'s previous message |
ALLOCATE_EXTERN is applied in FX2regs.H as follows.
#ifdef ALLOCATE_EXTERN #define EXTERN #define _AT_ _at_ #else #define EXTERN extern #define _AT_ ;/ ## / #endif EXTERN xdata volatile BYTE GPIF_WAVE_DATA _AT_ 0xE400; EXTERN xdata volatile BYTE RES_WAVEDATA_END _AT_ 0xE480; ... // more than one hundred EXTERNs When ALLOCATE_EXTERN is '#define'd, variables are declared there. xdata volatile BYTE GPIF_WAVE_DATA _at_ 0xE400; When it is NOT '#define'd, variables are referenced by extern. extern xdata volatile BYTE GPIF_WAVE_DATA ;// 0xE400; This is a well-known technique for 'C' header to share single header around source files. 'C' syntax requires to declare global variables in one place, and to reference it with 'extern' in other files. Usually, this first declaration and extern references are done in separate files. Using this technique, it is combined into a single file. The benefit of this technique is, - Saves time and effort for troublesome copy-paste and modification. - - This is great when the variables are more than one hundred like this case. - Eases code maintenance - - Revision is done in a single file without synchronizing separate files. Does EXTERN ALLOCATE will effect any port pins? It concerns to this line, PORTECFG = 0x08; // enable RXD0OUT PORTECFG (0xE672) is an FX2 xdata variable defined in FX2regs.H using this EXTERN. When ALLOCATE_EXTERN is not declared, PORTECFG points wrong address and this line doesn't work. Therefore, RXD0OUT wasn't enabled on the port, and you could see any signal on the pin. On the other hand, other UART mode than mode0 doesn't use RXD0OUT. So you didn't notice it. i will write IOE=0x0;
then after some delay again i will write IOE=0x1; Flip exactly single bit. As IOE is not bit-addressable, IOE &= ~0x01; // clear bit 0 IOE |= 0x01; // set bit 0 Tsuneo |