CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

spi_xfer error() on v.115 PCH?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ffotsch



Joined: 14 Sep 2008
Posts: 8

View user's profile Send private message

spi_xfer error() on v.115 PCH?
PostPosted: Wed Dec 15, 2010 6:09 am     Reply with quote

I am using a PIC 18f2550 with two spi slaves, one uses hardware spi and the other uses software spi. Here are my use statements:
Code:

#use spi(MODE=3, DI=PIN_a2, DO=PIN_a3, CLK=PIN_a1, BITS=16, STREAM=adxl)
#use spi(FORCE_HW,MODE=3,BITS=8,STREAM=eeprom)

I am using the spi_xfer(), here is an example of use:
Code:

spi_xfer(adxl,0x32|0xc0,8);//set read and multiple byte bits with b11000000 mask
x_sample.u_byte[0]=spi_xfer(adxl,0x00,8);

This code complied fine and worked fine until I upgraded to version 4.115, the compiler now generates this error on every spi_xfer() statement.

"Error 99 wrong pin for H/W"

Is my use statement wrong? Am I overlooking something or is this perhaps a bug in the new release?

Thanks!
collink



Joined: 08 Jan 2010
Posts: 137
Location: Michigan

View user's profile Send private message Visit poster's website

Re: spi_xfer error() on v.115 PCH?
PostPosted: Wed Dec 15, 2010 9:52 am     Reply with quote

I looked at the data sheet for that chip and it appears that the following are the hardware pins for SPI:

B0 = DI
B1 = Clock
C7 = DO

You are trying to use A1 - A3 for this. The hardware SPI must use the proper pins which is what the compiler is telling you. I have no idea why previous versions would not have complained. Maybe they were silently falling back to software SPI.
ffotsch



Joined: 14 Sep 2008
Posts: 8

View user's profile Send private message

PostPosted: Wed Dec 15, 2010 12:33 pm     Reply with quote

Yes, those are the hardware pins for SPI. However, it is my understanding and experience that spi can also be done in software without using the hardware pins. I have two spi devices on the same chip, the chip has only one H/W spi port. Thus, one of the two is H/W and the other is software. The H/W spi is connected to the pins you refer to and the S/W spi is connected to a1, a2, and a3. My understanding is that it is ok to use S/W spi without using the H/W spi pins on the controller.

Thanks for your reply.
collink



Joined: 08 Jan 2010
Posts: 137
Location: Michigan

View user's profile Send private message Visit poster's website

PostPosted: Wed Dec 15, 2010 12:44 pm     Reply with quote

ffotsch wrote:
Yes, those are the hardware pins for SPI. However, it is my understanding and experience that spi can also be done in software without using the hardware pins. I have two spi devices on the same chip, the chip has only one H/W spi port. Thus, one of the two is H/W and the other is software. The H/W spi is connected to the pins you refer to and the S/W spi is connected to a1, a2, and a3. My understanding is that it is ok to use S/W spi without using the H/W spi pins on the controller.

Thanks for your reply.


Sorry, I didn't see that the two statements had different streams so they should be different. You do seem to be using the proper stream. What happens if you reverse the two SPI definition lines so that the hardware one is defined first?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 15, 2010 4:08 pm     Reply with quote

If it worked in a previous version and it doesn't work in the latest version,
and there is no CCS explanation in the Readme.txt of different usage,
then it's likely a bug and needs to be reported to CCS.

In the vs. 4.115 announcement email that I got, they said this:
Quote:
Recent changes include:
4.115 PCD SPI defines SPI_XMIT... have been modified to operate the same as PCM and PCH
4.115 A number of device database errors have been fixed
4.115 A PIC24 bug with &= on 32 bit operands is fixed
4.115 New #USE TIMER library added

My guess is that they made a mistake when they upgraded the database
for the 18F2550 with respect to the hardware SPI module.

If you own the compiler, email CCS support about this bug.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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