LPC1769: SPI data problem when debugging

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

LPC1769: SPI data problem when debugging

832 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Devenda on Fri Jan 31 05:49:19 MST 2014
Hi


I'm having trouble using the Mbed SPI and SD functionality when debugging with the LPCXpresso (LPC1769).

When using the debug function the data comes out shifted.

I have measured the output using the bus pirate (because I can't use a scope at this moment) using this code to interface a 23LC1024 RAM chip:

#include "mbed.h"

//Instruction set
#define READ 0x03
#define WRITE 0x02
#define EDIO 0x3B
#define EQIO 0x38
#define RSTIO 0xFF
#define RDMR 0x05
#define WRMR 0x01

SPI serialMemory(P0_18, P0_17, P0_15); // mosi(J6-11), miso(J6-12), scl(J6-13)
DigitalOut CS(P0_16);//CS(J6-14)
DigitalOut Vcc(P0_23);//extra Vout (J6-15)

//setup
void SPIMEM_setup()
{
serialMemory.format(8, 0); //the memory module works in SPI mode 0: POL = 0 and PHA = 0
serialMemory.frequency(125000);

//Setup sequential mode: MODE REG = 0100 0000
CS.write(0);
//serialMemory.write(WRMR);
//serialMemory.write(0x40);
CS.write(1);
}

//single read from address(max 0x1FFFF)
int SPIMEM_readDataFromAddress(uint32_t address)
{
uint8_t receivedData;

CS.write(0);
serialMemory.write(READ);
serialMemory.write((uint8_t) (address >> 16) & 0xFF);
serialMemory.write((uint8_t) (address >> 8) & 0xFF);
serialMemory.write((uint8_t) (address) & 0xFF);
receivedData = serialMemory.write(0x00);
CS.write(1);

return receivedData;
}

//single write to address(max 0x1FFFF)
void SPIMEM_writeDataToAddress(uint32_t address, uint8_t data)
{
CS.write(0);
serialMemory.write(WRITE);
serialMemory.write((uint8_t) (address >> 16) & 0xFF);
serialMemory.write((uint8_t) (address >> 8) & 0xFF);
serialMemory.write((uint8_t) (address) & 0xFF);
serialMemory.write(data);
CS.write(1);
}

int main()
{
uint32_t i = 0;
uint32_t address = 0x1AAAA;
uint8_t data = 0xBB;
//Vcc.write(1);

SPIMEM_setup();

for (i = 0; i < 200; i++)
{
//CS.write(0);
//serialMemory.write(WRITE);
//serialMemory.write(0xAA);
//CS.write(1);
SPIMEM_writeDataToAddress(i, data);
SPIMEM_readDataFromAddress(i);
}
}


The strange thing is that after resetting (un-plugging en plugging the LPCXpresso back in) the code functions correctly.

Now, before this I also tested the SD functionality. This code doesn't run either when debugging but works perfectly when resetting the device!


Besides that I keep getting this error when starting a debug session:
Quote:
No source available for "0x1fff0080"

0 项奖励
回复
3 回复数

804 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Devenda on Mon Feb 03 02:58:53 MST 2014
Thanks for letting me know, I'm still using LPCXpresso 5, so this might be why its not functioning properly.
I'll look into it!
0 项奖励
回复

804 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Mon Feb 03 01:53:11 MST 2014
C and C++ are both supported development languages in LPCXpresso 6.

The address - 0x1fff0080 - that you are seeing makes it sound like your board is getting stuck in the built in bootloader. I would suspect a floating ISP pin.

http://www.lpcware.com/content/faq/lpcxpresso/debug-design

Regards,
LPCXpresso Support.
0 项奖励
回复

804 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Devenda on Sun Feb 02 12:35:17 MST 2014
I have not yet found a solution to this problem, but I understand that C++ isn't official supported. So to avoid further problems I stepped away from the LCPXpresso IDE and started using the Mbed online compiler, which functions perfectly.
0 项奖励
回复