hi, We are trying to use LPC3250 EMC for interfacing SRAM ,when we are writing a single value we are seeing2 chip select, 2 write pulses.
what can be the problem
Regards and Thanks Sumit
There could be numerous causes for the problem.
Your lack of detail (such as hardware/software configuratoin) make it virtually impossible to give a definitive answer.
An example of seeing two writes and two chip selects could occur if you are writing a single 32 bit word but with the EMC being configured for 16 bit access.
If your hardware is configured for 16 bit access, then this might be the expected result.
If your hardware is configured for 32 bit access, then this would almost certainly not be the expected result and a check of the EMC configuration would be sensible.
Hi,
Thanks for your reply.
When we set our EMC in 32 bit mode then our problem got solved.
But we want EMC to work in 16 bit mode then how should we write the data.
For 32 bit we are doing as shown below:
#define CS0 (*(volatile unsigned long *)(0xE0000000))
void main() { EMC0_init(); while(1) cs0=0x5555; }
What shall we do for 16 bit.
Regards & Thanks Sumit
Maybe this is a RAM timing problem. Have a look at the related user manual; they will tell you how to configure your EMC.
The code you have for accessing a location is as correct for 32 bit width as it is for 16 bit width.
However, when you access a 32 bit variable on a 16 bit bus you should expect two chip select pulses. Simply because to access the 32 bits two 16 bit accesses must occur.
For sake of completeness, if you wanted to carry out a single 16 bit access your code could be modified as follows:
#define CS0 (*(volatile unsigned short *)(0xE0000000)) void main() { EMC0_init(); while(1) cs0=0x5555; }
Thanks when we used the volatile short syntax problem solved.
But when we are trying to read same as shown below no chip select no read signal generated on the pin:
#define CS0_read_16 (*(volatile unsigned short *)(0xE0000000))
void main () { emc_init(); emc0_init(); while(1) { CS0_read_16=0x5555;
} }
void emc0_init(void) { //EMCStaticConfig0=0X00000082; //for 32 bit EMCStaticConfig0=0x00000081; //for 16 bit EMCStaticWaitWen0=0x00000001; //WaitWen0+1 EMCStaticWaitWr0=0x00000007; //WaitWr0+2 EMCStaticWaitRd0=0x00000007; EMCStaticWaitOen0=0x00000001; EMCStaticWaitTurn0=0x00000000; EMCStaticWaitPage0=0x00000000; EMCStaticExtendedWait=0x00;
delay(); EMCControl=0x00000001; // entering emc to Enable mode mode }
void emc_init(void) { //while((EMCStatus&0x00000001)==0x00000001);
EMCControl=0X00000000; // entering emc to disable mode EMCConfig=0X00000000; // 0th bit little endian mode only
}
What can be the problem
First - is there a reason why you avoid formatting your code as code? Do you feel that it gets too easy to read with proper formatting?
Secondly:
#define CS0_read_16 (*(volatile unsigned short *)(0xE0000000)) void main () { emc_init(); emc0_init(); while (1) { CS0_read_16=0x5555; } }
will expand into:
void main () { emc_init(); emc0_init(); while (1) { (*(volatile unsigned short*)(0xE0000000)) = 0x5555; } }
Exactly how much do you think that looks like a read? Doesn't it look like a write of the value 0x5555 to you?
The following have a slightly larger chance of actually performing a memory read:
my_var = CS0_read_16;
By the way - what is the meaning of the "read" part of the name of your #define? Is it to inform that you may only read - not write - using the pointer? Sometimes "const" can be a nice keyword to have the compiler verify that attemts are not made to write to read-only variables.