|
|
View previous topic :: View next topic |
Author |
Message |
Pichuqy_1
Joined: 03 Aug 2010 Posts: 38
|
|
Posted: Fri Aug 06, 2010 3:13 pm |
|
|
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
|
|
Posted: Fri Aug 06, 2010 3:17 pm |
|
|
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
|
|
Posted: Fri Aug 06, 2010 3:59 pm |
|
|
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
|
|
Posted: Sat Aug 07, 2010 5:19 pm |
|
|
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
|
|
Posted: Sat Aug 07, 2010 6:29 pm |
|
|
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. |
|
|
|
|
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
|