This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problems with communication between C167 and LM629N

Hi all,

i'm a student from germany. I got a problem with the addressing of an external bussystem. My C167 controls six LM629N (Precision Motion Controller IC) for an robot. A SN74LS138 Demux selects the LM629N. The Connections are:

SN74LS138 : C167
/E1 : /CS4
A2 : A3
A1 : A2
A0 : A1

LM629N : C167
D0..D7 : D0..D7
/WR : /WRL
/RD : /RD-U
/PS : A0

SN74LS138 : LM629
/O0../O5 : /CS

My concrete Questions:
1) How to setup the options for memoryspace with addrsel4/buscon4?
2) Wich Memorymodel should i use?
3) How can i read and write data to the LM639N.

I did tones of tries with all possible options,memory-models, near far and huge declarations for pointer, addrsel/buscon settings, dpp configuration .... (for example:

#define BASIS_ADRESSE 0x50000
unsigned char readLM629(unsigned char Achse)
{
 near unsigned char *pointer;
 pointer = ((near unsigned char*)(Achse*2 | BASIS_ADRESSE));
 return *pointer ;
}
just want to read out data from the LM629N)

But the robot didn't move any time :( The configuration was setup by to students years ago and allready worked on their laptop. But want work here :(

If anything missing - ask, i will give my best to explain the construction!

big thx
arthur

Parents Reply Children
  • Hello Reinhard,

    yesterday i realized that keil is an compiler for c source. But my university is using Tasking EDE. Is there anything different? My Prof told me that keil is more powerfull in compiling.
    Does your link also work with Tasking EDE compiling?

    Thx for your quick answer :)

    Greetings
    Arthur

  • This is a Keil forum so I will only answer Keil questions and answers here.

    You didn't say what you were doing with the other chip selects. Please review the C167 user's manual as not all overlays of chips selects are allowed and will lead to erroneous bus cycles if not properly configured. For example ADDRSEL4 may not overlap ADDRSEL2 or ADDRSEL1. Secondly you also need to confirm your Port0 configuration (hardware) that you have enabled 5 chip selects. It is not possible for software to change the number of chip selects on the C167 (XC16x yes). Enclosed is an example of an 8-bit demux bus and a 4Kbyte address window on /CS4 at 0x210000. Please change to what you need! As this is just a reference.

    #include <reg167.h>
    #include <intrins.h>
    
    volatile char far *pLM629N;
    
    #define LM629N (0x210000lu)
    char in;
    char out;
    
    void main(void) {
    
      BUSCON4 = 0x042Eu;
      ADDRSEL4 = 0x2100u;
    
      pLM629N = (char far *)(LM629N);
      out = 0x55;
    
      *pLM629N = out;
      in = *pLM629N;
    
      for(;;) {
         _nop_();
      }
    }
    

    Kind regards,
    Chris

  • "yesterday i realized that keil is an compiler for c source. But my university is using Tasking EDE. Is there anything different?"

    EDE is described on Tasking's website:
    http://www.tasking.com/resources/technologies/ede/

    Thus it sounds like EDE is Tasking's equivalent of uVision - it is not a language or a compiler, it is just a "front-end" to the tools.
    Just like uVision.

    "My Prof told me that keil is more powerfull in compiling."

    and would you expect that to be disputed on a Keil forum...?! ;-)

  • @ andy hehe :=)
    @topic
    Thx for the answers. First i think the configuration of CS Signals is right. Selected 5 CS Signal with Switch 3 on the board.
    On Friday i could establish a connection to the LM629N. I used the huge variable declaration instead of far. The students befor me used far and i believed that they know what they did.
    So it wasn't a question of the options, than the right configuration of the functions (also huge) and the variable pointer.
    I also loaded the keil compiler. But it would take to much time for me to work with a nother compiler - having just 3 more days to complete the project.

    So great thanks to all of you. I wish you a nice 1. Advent :)

    Arthur

  • Hi Arthur,

    You need to know what memory model you are using and really understand the implications of the hardware of the C167? The Keil compiler for the C166 toolchain has a great number of configurations to provide the user with the best choice for their respective need. I would guess that you are using the default setting of "small" which means functions are assumed to be less than 64Kbyte and variables are assumed to be near. This means that when you define a function as "void foo (void)" in the small memory model the compiler really sees this as "void near foo(void)". Therefore if you need to call a function that is not in the same 64kbyte boundary you need a call that would cause the code segment pointer of the C167 to be updated. This would happen as you said using the "huge" keyword but it would also have worked if you had used "far". As for the variable pointer this again needs understanding of what the C166 hardware does. The "huge" keyword on a variable will issue an extended segment (EXTS) instruction which allows for a bypass to the segment to access the variable (allowing the object to be a maximum size of 64Kbyte). The "far" keyword on a variable will issue an extended page (EXTP) instruction which allows for a bypass of the data page pointer to access the variable (allowing the object to be a maximum size of 16Kyte).

    So hopefully you don't take this as ranting but it is very important that you understand why you need to make these adjustments to your code.

    Kind regards,
    Chris