Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
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

List of 44 messages in thread
TopicAuthorDate
fx2 serial port mode0            01/01/70 00:00      
   How to post legible code            01/01/70 00:00      
      I dunno            01/01/70 00:00      
      thanks            01/01/70 00:00      
         who is is this microresistor expert?            01/01/70 00:00      
         You, too, can be expert!            01/01/70 00:00      
            well, I did            01/01/70 00:00      
               But of course, you prefer to be obtuse            01/01/70 00:00      
                  no, I am not 'obtuse', just trying to get to the s            01/01/70 00:00      
   Legible code posted,please continue the discussion            01/01/70 00:00      
      That's better            01/01/70 00:00      
         rxd0out            01/01/70 00:00      
            REN_0            01/01/70 00:00      
         I'm puzzled            01/01/70 00:00      
            Bible Time!            01/01/70 00:00      
               Separate RXD0OUT pin            01/01/70 00:00      
                  Now I'm confused, too!            01/01/70 00:00      
                  data is not transmitting            01/01/70 00:00      
               OUCH!            01/01/70 00:00      
                  1Mhz clock            01/01/70 00:00      
                     reply            01/01/70 00:00      
   why no body is replying            01/01/70 00:00      
      Richard, where are you, he is using mode 0!            01/01/70 00:00      
         I didn't have anything to contribute ...            01/01/70 00:00      
      Because no particular error            01/01/70 00:00      
         RxD0out            01/01/70 00:00      
            Debug monitor?            01/01/70 00:00      
               connected to SI0-0            01/01/70 00:00      
                  Debug monitor!!            01/01/70 00:00      
                     mode1            01/01/70 00:00      
                        monitor switches the UART mode            01/01/70 00:00      
                           Tested with SIO-1            01/01/70 00:00      
                              Monitor comes from EEPROM?            01/01/70 00:00      
                                 problem solved            01/01/70 00:00      
                                    Not yet            01/01/70 00:00      
                                       12Mhz            01/01/70 00:00      
                                          Then what was the cause, after all?            01/01/70 00:00      
                                             Don't leave it unsolved            01/01/70 00:00      
                                                ALLOCATE_EXTERN??            01/01/70 00:00      
                                                   ALLOCATE_EXTERN fixes FX2 xdata registers addr            01/01/70 00:00      
                                                      EXTERN ALLOCATE            01/01/70 00:00      
                                                         ALLOCATE_EXTERN fixes PORTECFG address            01/01/70 00:00      
                                                            EXTERN_ALLOCATE            01/01/70 00:00      
                                                               Its ALLOCATE_EXTERN .not EXTERN_ALLOCATE            01/01/70 00:00      

Back to Subject List