![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
aaron
Joined: 07 Sep 2003 Posts: 6
|
18F452 SPI DEBUG problem |
Posted: Tue Sep 21, 2004 11:05 am |
|
|
Hi folks,
Something realy strange happens when I run the PIC code without the debugging cable. The PIC talks SPI as a slave with another processor (master) and everything goes fine if the debug cable is plugged in. If I recompile the code without the DEBUG and program it into the PIC it looks like the PIC is able to just receive data but it stops sending. Not a single line of code is changed. If I scope the data out line all I see is a big flat line. Nothing.
Any ideas ? Has anyone seen anything like this ?
On the PIC errata they talk about some issues with the MSSP hardware but I don't think is the case.
Any clues about what is going on ? Same code works with the debugger and doesn't when the code is programmed into the target.
Thanks.
-------
Here is my setup:
CCS PCH C Compiler, Version 3.186, 18728
Debugger : MPLAB ICD2
Config code:
Code: |
#include <18F452.h>
#device *=16
#use delay(clock=40960000)
#fuses H4,PUT,STVREN,NOWDT,NOLVP,NOBROWNOUT,CCP2C1,NODEBUG
#use fast_IO(A)
#use fast_IO(B)
#use fast_IO(C)
#use fast_IO(D)
#use fast_IO(E)
|
I configure the SPI by writting directly to the registers:
Code: |
SSPSTAT = 0x00; // SSPSTAT: SMP=0, CKE=0, D//A=0, P=0, S=0, R//W=0, UA=0, BF=0
SSPCON1 = 0x24; // SPI slave mode, clock = SCK pin, /SS pin control enabled
|
|
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 21, 2004 11:26 am |
|
|
The first question is, have you been able to make any program
work in stand-alone mode ? Or is it just this one program that doesn't
work ? |
|
![](templates/subSilver/images/spacer.gif) |
aaron
Joined: 07 Sep 2003 Posts: 6
|
|
Posted: Tue Sep 21, 2004 11:52 am |
|
|
Yes. My program runs ok. The ONLY issues is the SPI traffic from PIC to the other processor. Nothing goes out. Everything else seems to work fine. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 21, 2004 12:24 pm |
|
|
I don't have PCH 3.186, so I used vs. 3.188. Also, my test board
has a 18F458 on it, instead of a 18F452, but they are similar chips.
I made the following simple test program, and it works.
The PIC puts out groups of pulses on the SCK and SDO pins.
I suggest you try this program. Change the preprocessor
statements as required, to match your hardware.
It should work. If your own program doesn't work, then
post a test program, similar to the one I've done below,
but with the methods that you're using. ie., #fast_io,
PLL x 4 oscillator mode, etc. What I will be looking for
is things like the proper set_tris_c() statement, proper
declarations of register addresses by use of the #byte
statement, etc. So make sure you post a full test
program, and not just code fragments.
Code: | #include <18F458.h>
#fuses XT, NOWDT, PUT, PROTECT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud = 9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//========================================
void main()
{
printf("Start\n\r");
setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_16);
while(1)
{
spi_write(0x55);
delay_us(100);
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Tue Sep 21, 2004 1:17 pm |
|
|
The code listing that you posted is very simple and indeed it should work. Is simple because the PIC is configured as a MASTER.
In my case the PIC is configured as a SLAVE but when it has something to send over SPI "acts" like a MASTER. As I said the SPI is used for inter-processor communication. The bus access is guarded by a flip-flop and each processor has a line out to signal a new message. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 21, 2004 1:28 pm |
|
|
Well, if you want me to work on it, you'll have to post a
small test program. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|