LPC1227 SPI problem

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

LPC1227 SPI problem

934 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by matutef1 on Fri Nov 23 09:29:53 MST 2012
I'm trying to use a spi flash memory (Atmel AT45DB041) which I have already used with a LPC1756 with no problems. But i can't get it working with LPC1227.
I use manual chip selection, I see the clock signal and it looks good, even MOSI and MISO signals are good. But I always read a 0 on DR register.
I've tried several pieces of code, but I always read a 0 on DR.
Does anyone have a similar problem or a working piece of code that could help me?
0 项奖励
回复
7 回复数

879 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by haricharan on Fri Sep 06 02:50:49 MST 2013
@capiman
Thank u for ur answer.
But i could not able to fix what was the problem?

My Code is as follows which is attached. Please see and reply me.



0 项奖励
回复

879 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Sphoenix on Thu Sep 05 03:44:32 MST 2013
Thanks for your reply capiman !

My previous message was delete when i tried to edit it.

Maybe a part of the solution here, thanks capiman : http://www.lpcware.com/content/forum/spi-lpc43xx-always-return-0#comment-1131904
0 项奖励
回复

879 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Sphoenix on Thu Sep 05 03:39:24 MST 2013
@capiman

I go post on the 43xx forum !
The SPI_CR_MSTR_Msk if define as
(1 << SPI_CR_MSTR_Pos) wich make 0xA0 when i printed it on debug (the value i wanted)

Thanks for reply !

EDIT : Solution on this topic, thanks capiman ! => http://www.lpcware.com/content/forum/spi-lpc43xx-always-return-0#comment-1131904
0 项奖励
回复

879 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by capiman on Thu Sep 05 01:21:23 MST 2013
@haricharan
Can you post the code you are using?
You know that with SPI you can't just read something from DR.
Only when you send 1 byte and wait till it is finished and wait till you have received something,
you can read 1 byte from DR.
There is no help with "I've tried several pieces of code". Try to understand the code
you are using and try to fix what is wrong.
0 项奖励
回复

879 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by capiman on Thu Sep 05 01:18:49 MST 2013
@all
Please create your own threads if you want to report a problem, which is different to the original post.
You can off course add a link to the old thread.
Especially when the subject says: LPC1227 and your problem is on a completely different uC like LPC4357,
this leads only to the use of the wrong documentation and hints.

@Sphoenix
In your init routine, you seem to use SPI_CR_MSTR_Msk, which looks like being a mask for a certain field, no real value.
Can you check what value SPI_CR_MSTR_Msk has and what value LPC_SPI->CR gets and if this is really
the value you want to have in register CR (compare with user manual!!!).
I have not looked into your other code.
0 项奖励
回复

879 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Sphoenix on Thu Sep 05 01:10:05 MST 2013
Hello,

I'm having the same problem on LPC4357 with MAX11200 (EDIT : i already use spi with MAX11200 on arduino uno with success).
I checked the MOSI, MISO and SLCK line with a scope and they are good (they nerver send 0).
I tried to connect MOSI and MISO line but still 0 on DR.

Here the functions i use to init and shift data :

void init_protocol()
{
  LPC_SPI->CR = SPI_CR_MSTR_Msk;
  LPC_SPI->CCR = 128;

  LPC_SCU->SFSP3_6 = 1; // MISO
  LPC_GPIO_PORT->DIR[0] &= ~(1<<6) | 0;
  LPC_SCU->SFSP3_7 = 1; // MOSI
  LPC_GPIO_PORT->DIR[5] |= (1UL << 10) | 0;
  LPC_SCU->SFSP3_3 = 1; // SCK
  LPC_SCU->SFSP3_8 = 4; // SSEL
  LPC_GPIO_PORT->DIR[5] |= (1UL<<11) | 0;
}

uint32_t spi_transfert(int data)
{
  uint32_t tmp;

  LPC_SPI->DR = data;
  while (!(LPC_SPI->SR & SPI_SR_SPIF_Msk))
  {
  };
  tmp = LPC_SPI->DR;
  return (tmp);
}
0 项奖励
回复

879 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by haricharan on Wed Sep 04 20:51:39 MST 2013
Me too had same problem. I'm trying to use a spi flash memory (Atmel SST25VF064C), i can't get it working with LPC1227.
I see the clock signal and it looks good, even MOSI and MISO signals are good. But I always read a 0 on DR register.
I've tried several pieces of code, but I always read a 0 on DR.
Does anyone have a similar problem or a working piece of code that could help me?
0 项奖励
回复