Problem with SPI0

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with SPI0

4,913 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by furkan.yuksel on Wed Jun 08 05:21:20 MST 2011
Hi, I'm trying to control two spi devices using spi0 and spi1 ports. However, spi0 doesn't work even spi1 works correctly.

I switched devices on ports 0 and 1 and againg device which is connected to spi0 did not respond, but it was fine with spi1.

What can my problem be ?
0 Kudos
Reply
32 Replies

4,331 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by faizal on Tue Jun 28 07:34:51 MST 2011
It was my silly fault. I thought it's Vout. Now my spi works fine.:)
Thanks a lot for your help, Zero and Rob65.
0 Kudos
Reply

4,328 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Mon Jun 27 07:03:29 MST 2011

Quote: Zero
Are you using VIN (4.5-5.5V) to power your ADE7953 :confused:



I had the same question.
VIN is the INPUT for the LPCXpresso board, it does not carry a 5V signal when using the LPCXpresso.


Quote:

1. I can debug my code step by step if i dont connect to ADE7953.  But,when i connected to ade7953 then i clicked debug,i got error said :
02: Failed on connect Em(07). Bad ACK returned from status.
And if i connected to ade7953,after have clicked resume(in debugging  mode), i got error said : 15: Target error from Register access.



This tells me that you have a problem with the connections of your ADE7953.
Somehow you are either short circuiting the power to your lpc or you are creating a short circuit on one of the SWD pins.

Please use an oscilloscope or multimeter to confirm your connections.

Rob
0 Kudos
Reply

4,328 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jun 27 06:50:45 MST 2011
Are you using VIN (4.5-5.5V) to power your ADE7953 :confused:
0 Kudos
Reply

4,328 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by faizal on Mon Jun 27 06:44:02 MST 2011
The reset need to be always high. I didn't try without reset.
0 Kudos
Reply

4,331 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jun 27 06:38:14 MST 2011
Don't know what 'Reset' of your board is, but did you try to work without Reset connection ?
0 Kudos
Reply

4,331 Views
lpcware
NXP Employee
NXP Employee

Content originally posted in LPCWare by faizal on Mon Jun 27 06:00:40 MST 2011
1. I can debug my code step by step if i dont connect to ADE7953. But,when i connected to ade7953 then i clicked debug,i got error said :
02: Failed on connect Em(07). Bad ACK returned from status.
And if i connected to ade7953,after have clicked resume(in debugging mode), i got error said : 15: Target error from Register access.

2. I use ADE7953 Evaluation Board. As u can see in the attached picture picture, i only connected MOSI(PIO0_9), RESET(PIO0_0), CS(PIO0_2), SCLK(PIO0_6), MCU_VDD(VIN (4.5-5.5V)), MISO(PIO0_8) and GND(GND). The others pins are not used. I've used the same connection for micro-controller AT90PWM3B and it worked for spi.

3. Yes, im using LPCxpresso (link and target lpc1114).

4. No, i didn't try to enable vector catch.

0 Kudos
Reply

4,331 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jun 27 05:04:43 MST 2011
1. When does this error occur? When you start debugging or can you step through your code?

2. How did you connect LPC1114 and ADE7953 exactly?

3. Are you still using LPCXpresso or own hardware?

4. Did you try to enable Vector catch?

5. Please export and post the whole project.
0 Kudos
Reply

4,331 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by faizal on Mon Jun 27 04:46:03 MST 2011
I've changed USE_CS 0, so PIO0_2 is GPIO and always high.

uint32_t newBUFSIZE=3;
uint8_t newbuf[newBUFSIZE];
uint32_t newBUFSIZE2=4;
uint8_t newbuf2[newBUFSIZE];

GPIOSetValue( PORT2, 0, 0 );
newbuf[0]=0x03;newbuf[1]=0x1C;newbuf[2]=0x80;
SSP_Send( SSP_NUM, (uint8_t *)newbuf, newBUFSIZE);
SSP_Receive( SSP_NUM, (uint8_t *)newbuf2, newBUFSIZE2 );
GPIOSetValue( PORT2, 0, 1 );


And still when i connected lpc1114 to ADE7953 ( MOSI,MISO,SSEL(p0_2) and SCK(p0_6)), i have the same error.
0 Kudos
Reply

4,331 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jun 27 03:02:56 MST 2011
You defined USE_CS 1, so PIO0_2 isn't GPIO any more (see:SSP_IOConfig())

GPIOSetDir( PORT0, 2, 1 );
GPIOSetValue( PORT0, 2, 1 );
is nonsense.
0 Kudos
Reply

4,331 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by faizal on Mon Jun 27 02:53:30 MST 2011
Im sorry, i thought it has something to do with ssp,so i posted here. Next time,i'll post in new thread.

Yes ADE7953 CS is low. I've checked using oscilloscope.
0 Kudos
Reply

4,331 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Mon Jun 27 02:46:20 MST 2011
Please open a new Thread for a new problem :)

Is your ADE7953 CS low?
0 Kudos
Reply

4,330 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by faizal on Mon Jun 27 02:29:19 MST 2011
Hello,

Im trying to communicate with ADE7953 energy-meter using LPC1114 via ssp. I use the example code in lpcxpresso.examples.lpc1114.302 (I've attached ssp.c and ssp.h). Im trying to read a value of a register in ADE7953. When i debugged the code without any connection,i had no error,but when i connected MOSI,MISO,SSEL(p0_2) and SCK(p0_6) to ADE7953, i got error said = Target reported error Reason 10: could not start execution from stop.:(
When i clicked ok, i got this error = target reports errors
Reason:
15:target error from register access.

Is there something wrong with my code?
0 Kudos
Reply

4,330 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Fri Jun 10 13:00:49 MST 2011
Which pin is the SCK for your system?
P0.6, P0.10 or P2.11 ???

Rob
0 Kudos
Reply

4,330 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jun 09 01:44:50 MST 2011

Quote: furkan.yuksel
....it still does not work :(...



So what is not working? What did you scope at your SPI0? What is your debugger doing while 'it still does not work'?

Perhaps you should post your project and let someone else solve your problem :confused:
0 Kudos
Reply

4,330 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by furkan.yuksel on Thu Jun 09 01:33:06 MST 2011

Quote: Zero
See:

http://support.code-red-tech.com/CodeRedWiki/UsingPrintf

So it's slow and bitchy and not made to use it in time critical programs :mad:




But even when I disable semihosting, it still does not work :( I cannot undertand what is wrong :( whatelse can efect the spi0 :(
0 Kudos
Reply

4,330 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jun 09 01:10:29 MST 2011

Quote:

[U][B]Important notes about semihosting[/B][/U]

...it is normally advisable to[B][COLOR=Red] avoid the use[/COLOR][/B] of semihosting... :eek:

See:

http://support.code-red-tech.com/CodeRedWiki/UsingPrintf

So it's slow and bitchy and not made to use it in time critical programs :mad:
0 Kudos
Reply

4,330 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by furkan.yuksel on Thu Jun 09 00:45:18 MST 2011

Quote: Zero
Since you are not using SSEL0, it can't be a problem with it  :)
And if PIO0_2 as GPIO is just used for chip select (= active low) your debugger and a few breakpoints can help you to see if there's happening something unexpected.
If it's high it just shows that SPI0 is not in use at the moment. And that's no surprise if printf is working...
I hope you don't use semihosting printf...



Yes, actually I'm using semihosting printf. Why, can it cause problem to spi?
0 Kudos
Reply

4,330 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jun 09 00:31:12 MST 2011
Since you are not using SSEL0, it can't be a problem with it  :)
And if PIO0_2 as GPIO is just used for chip select (= active low) your debugger and a few breakpoints can help you to see if there's happening something unexpected.
If it's high it just shows that SPI0 is not in use at the moment. And that's no surprise if printf is working...
I hope you don't use semihosting printf...
0 Kudos
Reply

4,330 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by furkan.yuksel on Wed Jun 08 23:35:06 MST 2011

Quote: Zero
So you have checked your IOCON setting for PIO0_2? It's really GPIO?

And you have scoped PIO0_2, it's really switching?



I think you are right, I reilize that there is inconsistency on working of SSEL0 on P0.2. But I measured it and it was fine while printf functions are not in use, however, when I try to use printf P0.2 stays high all the time.
0 Kudos
Reply

4,330 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Jun 08 08:21:13 MST 2011
So you have checked your IOCON setting for PIO0_2? It's really GPIO?

And you have scoped PIO0_2, it's really switching?
0 Kudos
Reply