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

Library to A/D (ADC101S021) by SPI
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Pichuqy_1



Joined: 03 Aug 2010
Posts: 38

View user's profile Send private message MSN Messenger

PostPosted: Fri Aug 06, 2010 3:13 pm     Reply with quote

1_ My CCS compiler version is 4.105.

2_I don't draw it, but I have one in the board.

I want to ask you, Can I use use_spi with this version of ccs c?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 06, 2010 3:17 pm     Reply with quote

Quote:
Can I use use_spi with this version of ccs c?

Yes, you can use it. It probably works.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 06, 2010 3:59 pm     Reply with quote

I just noticed something that you're doing. I hadn't looked at your LCD
display routine, because I was using RS-232. But upon looking at it I saw this:

In the code below, you're passing a 16-bit value read from the A/D to
your LCD display routine:
Quote:

void main()
{
int16 adc_result;
.
.
.
while(1)
{
adc_result =read_adc101s021();

displayVoltage(adc_result);


But then below, you've set the function parameter as an 'int'. That's only
8 bits in CCS. It can't hold the 0 to 1023 result. It will truncate the upper
byte, giving false results:
Quote:

void displayVoltage(int adc)
{
char voltage[9];
char unidad [] ="LISY300:";
sprintf(voltage, "%f", (float)adc);
voltage[4] = '\0';
glcd_text57(0, 0, voltage, 1, 1);
glcd_text57(80, 0, unidad, 1, 1);
}
Pichuqy_1



Joined: 03 Aug 2010
Posts: 38

View user's profile Send private message MSN Messenger

PostPosted: Sat Aug 07, 2010 5:19 pm     Reply with quote

Hi PCM programmer: I change it:
Quote:

void displayVoltage(int16 adc)
{

char voltage[9];
char unidad [] ="LISY300:";
sprintf(voltage, "%f", (float)adc);
voltage[4] = '\0';
glcd_text57(0, 0, voltage, 1, 1);
glcd_text57(80, 0, unidad, 1, 1);
}

I'm simulating the circuit with ICD2 debugger and watch the result:
This is the first that I see in the LCD.
result=0x03FE = 1022


But then I see this in the LCD
result=0x001E = 30


I think that the program is working ok.
I don't know what to do.. I'll try with the 74HCT125
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Aug 07, 2010 6:29 pm     Reply with quote

We already know the hardware SPI driver (which you just tested) will not
work reliably with the PIC running at +5v and the ADC at +3.3v.


Quote:

I've tried to use software SPI, with the program that you give me but it's
show me 30 approximately.

What happens if you try the software driver, with the fixed LCD display
routine ? That's what I expected you to do. Try it.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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