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 ; }
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_(); } }