EmbeddedRelated.com
Forums

interfacing ADS7825 with lpc2148 blueboard

Started by shweta July 31, 2010
--- In l..., Shweta Parmar wrote:
>
> I am doing some changes like this:
>
> #define ADC_BYTE (1 << 4)
> #define ADC_CONVERT (1 << 6)
> #define ADC_BUSY (1 << 5)
>
> #define ADC_D0 (1 << 15)
> #define ADC_D1 (1 << 16)
> #define ADC_D2 (1 << 17)
> #define ADC_D3 (1 << 18)
> #define ADC_D4 (1 << 19)
> #define ADC_D5 (1 << 20)
> #define ADC_D6 (1 << 21)
> #define ADC_D7 (1 << 22)
>
> uart1 data is changes automatically. when my input is 0Volt then it display
> like this on uart1:
> 3B 57 57 7F 7F 23 23 7F 7F 7F 7F 41 41 49 49 7F 7F 59 59 7F 7F 79 79 7F 7F
> 08 08 7F 7F 59 59 7A 7A 7F 7F 7F 7F 7F 7F 6D 6D 7F 7F 71 71 5D 5D 7F 7F 7F
> 7F 4D 4D 43 43 7F 7F 11 11 2B 2B 3F 3F 7F 7F 0B 0B 43 43 2E 2E 7F 7F 7F 7F
> 0F 0F 6F 6F 5F 5F 63 63 7D 7D 79 79 49 49 3F 7F 7F 7B 7B 6F 6F 7F 7F 37 37
> 65 65 7F 7F 4B 4B 7F 7F 5C 5C 7F 7F 5F 5F 05 05 27 27 43 43 75 75 01 01 13
> 13 3F 3F 39 39 5F 5F 37 37 3F 3F 3F 3F 7F 7F
> data is changed automatically. data is not change with the potentiometer.
> what can i do?
>
You are a very long way from understanding how the GPIO pins are used.

The ADS7825, when operated in parallel mode, has an 8 bit output bus and it is NOT bidirectional. Therefore, there is no need to EVER manipulate IOxDIR once the pin directions are set.

I don't know why your data is erratic but all you are sending to the UART is the contents of the IODIR register and that information is meaningless.

Further, you aren't converting the binary values to hex so that they can be displayed properly with Hyperterminal - but I have already discussed this and the soluton.

To loop on BUSY' you need to do something like:

while ((IO0PIN & ADC_BUSY) == 0)
;

Referencing IO0PIN causes the port to be read (in this case). The value is then masked with the BUSY' flag bit and tested for 0 which indicates the device is busy.

Richard

An Engineer's Guide to the LPC2100 Series

thanks, for your help. i am doing changes as you said.
while ((IO0PIN & ADC_BUSY) == 0)
;
i am getting value on uart for 1Volt like this:
7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7F 7F 70 70 70 70 70
70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70
70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70
70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70
70 70 70 70 70 70 70 70 70 70 70 70 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F
7F 7F 7F 7F 7F 7F 7F 7F 7F

need your help
On Wed, Aug 4, 2010 at 9:44 PM, rtstofer wrote:

> --- In l... , Shweta Parmar
> wrote:
> >
> > I am doing some changes like this:
> >
> > #define ADC_BYTE (1 << 4)
> > #define ADC_CONVERT (1 << 6)
> > #define ADC_BUSY (1 << 5)
> >
> > #define ADC_D0 (1 << 15)
> > #define ADC_D1 (1 << 16)
> > #define ADC_D2 (1 << 17)
> > #define ADC_D3 (1 << 18)
> > #define ADC_D4 (1 << 19)
> > #define ADC_D5 (1 << 20)
> > #define ADC_D6 (1 << 21)
> > #define ADC_D7 (1 << 22)
> >
> > uart1 data is changes automatically. when my input is 0Volt then it
> display
> > like this on uart1:
> > 3B 57 57 7F 7F 23 23 7F 7F 7F 7F 41 41 49 49 7F 7F 59 59 7F 7F 79 79 7F
> 7F
> > 08 08 7F 7F 59 59 7A 7A 7F 7F 7F 7F 7F 7F 6D 6D 7F 7F 71 71 5D 5D 7F 7F
> 7F
> > 7F 4D 4D 43 43 7F 7F 11 11 2B 2B 3F 3F 7F 7F 0B 0B 43 43 2E 2E 7F 7F 7F
> 7F
> > 0F 0F 6F 6F 5F 5F 63 63 7D 7D 79 79 49 49 3F 7F 7F 7B 7B 6F 6F 7F 7F 37
> 37
> > 65 65 7F 7F 4B 4B 7F 7F 5C 5C 7F 7F 5F 5F 05 05 27 27 43 43 75 75 01 01
> 13
> > 13 3F 3F 39 39 5F 5F 37 37 3F 3F 3F 3F 7F 7F
> > data is changed automatically. data is not change with the potentiometer.
> > what can i do?
> > You are a very long way from understanding how the GPIO pins are used.
>
> The ADS7825, when operated in parallel mode, has an 8 bit output bus and it
> is NOT bidirectional. Therefore, there is no need to EVER manipulate IOxDIR
> once the pin directions are set.
>
> I don't know why your data is erratic but all you are sending to the UART
> is the contents of the IODIR register and that information is meaningless.
>
> Further, you aren't converting the binary values to hex so that they can be
> displayed properly with Hyperterminal - but I have already discussed this
> and the soluton.
>
> To loop on BUSY' you need to do something like:
> while ((IO0PIN & ADC_BUSY) == 0)
> ;
>
> Referencing IO0PIN causes the port to be read (in this case). The value is
> then masked with the BUSY' flag bit and tested for 0 which indicates the
> device is busy.
>
> Richard
>
>
>
--- In l..., Shweta Parmar wrote:
>
> thanks, for your help. i am doing changes as you said.
> while ((IO0PIN & ADC_BUSY) == 0)
> ;
> i am getting value on uart for 1Volt like this:
> 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7F 7F 70 70 70 70 70
> 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70
> 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70
> 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70
> 70 70 70 70 70 70 70 70 70 70 70 70 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F
> 7F 7F 7F 7F 7F 7F 7F 7F 7F
>
> need your help
>

Delete your original file and post your new code.

Richard

i upload my file with name "ADS LCD.rar".

On Thu, Aug 5, 2010 at 7:24 PM, rtstofer wrote:

> --- In l... , Shweta Parmar
> wrote:
> >
> > thanks, for your help. i am doing changes as you said.
> > while ((IO0PIN & ADC_BUSY) == 0)
> > ;
> > i am getting value on uart for 1Volt like this:
> > 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7B 7F 7F 70 70 70 70
> 70
> > 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70
> 70
> > 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70
> 70
> > 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70 70
> 70
> > 70 70 70 70 70 70 70 70 70 70 70 70 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F 7F
> 7F
> > 7F 7F 7F 7F 7F 7F 7F 7F 7F
> >
> > need your help
> > Delete your original file and post your new code.
>
> Richard
>
>
>
--- In l..., Shweta Parmar wrote:
>
> i upload my file with name "ADS LCD.rar".
>
In main() the statement

IO0PIN = ADC_DATA_CLR;

is incorrect. You would be setting ALL of the pins to the contents of the IOCLR register which is a WRITE ONLY register. Delete the statement.

I assume CS' is wired to ground. There's a wiring diagram in the datasheet - Figure 1.

Be certain the wait(4) statement isn't holding rc low too long. rc must go high LONG before BUSY' goes high. Check the timing specs.

Richard

thanks Richard for your help.
i am doing changes as you said:
ADC_CTRL_CLR = ADC_BYTE;
ADC_CTRL_CLR = ADC_RC;
wait(2);
ADC_CTRL_SET = ADC_RC;
//IO0PIN = ADC_DATA_CLR;
while((IO0PIN & ADC_BUSY) == 0);
wait(4);
temp = IO0PIN;
.......
then also i am getting same output as i told previous message.

On Fri, Aug 6, 2010 at 12:02 PM, rtstofer wrote:

> --- In l... , Shweta Parmar
> wrote:
> >
> > i upload my file with name "ADS LCD.rar".
> > In main() the statement
>
> IO0PIN = ADC_DATA_CLR;
>
> is incorrect. You would be setting ALL of the pins to the contents of the
> IOCLR register which is a WRITE ONLY register. Delete the statement.
>
> I assume CS' is wired to ground. There's a wiring diagram in the datasheet
> - Figure 1.
>
> Be certain the wait(4) statement isn't holding rc low too long. rc must go
> high LONG before BUSY' goes high. Check the timing specs.
>
> Richard
>
>
>
Sweta,

Though I can't help to resolve your problems, I appreciate your spirit of
not giving up! Best luck!

Mahesh Vyas
--- In l..., "Archana Automation" wrote:
>
> Sweta,
>
> Though I can't help to resolve your problems, I appreciate your spirit of
> not giving up! Best luck!
>
>
>
> Mahesh Vyas
>

Well, let's clear up the UART output first. There is a file conio.zip in the files folder that has a collection of conversion routines including signed decimal. For this iteration, puthexword(n) is probably the way to go. It will send 0x???? out the UART. For the project in which this routine was used, a word was 16 bits.

So, after you put the two bytes together, do:

puthexword(value);
putCRLF();

I don't like this version because putc(ch) doesn't properly handle \n by itself. What should happen is that putc should recognize \n and emit a \r followed by the \n. But who cares? These routines work.

You should be able to send strings usng puts(s).

The putc function is using the wrong UART for your application. Change it.

Go ahead and clean up the console output. Maybe add a signon message at the top of main(). Something like putline("Hello World!"); You need to be absolutely certain that serial IO is working before you worry about the A/D.

Richard