Setting up TouchScreenSensor

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Setting up TouchScreenSensor

Jump to solution
936 Views
dporada
Contributor III

I'm trying to use Processor Expert to set up reading a resistive touch screen with a K60.  Can I get some help setting up the I/O?  I can't seem to set up the Xplus1, Xminus1, Yplus1, Yminus1 bits.  There doesn't seem to be a drop down menu to select the pin names.

Am I using the wrong bean for my application?

Labels (1)
0 Kudos
1 Solution
624 Views
BlackNight
NXP Employee
NXP Employee

Hi Donald,

ok, that would be me :smileyhappy:.

The truth is: I have not tried (implemented) it for K60.

What you need to do/implement is what Petr explained above: to set up the pins so you can switch between input and output state. This you need to specify as code as below (example for ColdFire JM128 on the TWR-LCD module).

4404_4404.png

If I find some time, I could spend some time to do that thing for the K60 and the TWR-LCD.

View solution in original post

0 Kudos
10 Replies
624 Views
Petr_H
NXP Employee
NXP Employee

Please write more details on what touch screen do you use and what component are you using.

best regards

Petr Hradsky

Processor Expert Support Team

0 Kudos
624 Views
dporada
Contributor III

I'm using a Newhaven NHD-7.0-800480WF-CTXI#-T with a 4 wire resistive touch screen.  I am trying to use the "TouchScreenSensor" module.

Thanks,

Don

0 Kudos
624 Views
Petr_H
NXP Employee
NXP Employee

There is no support for LCD nor touch screen on Kinetis K60. I'm not sure what do you mean by "Touch Screen Sensor". It's probably a misunderstanding, the TSS_Library (stands for Touch Sensing Software) component does not handle resistive panels, it can handle only capacitive electrode touch sensors.

I think that the only option on K60 is to connect the touch panel to some 4 pins with ADC input of K60.

The application would basically need to :

Set X+ to some voltage, X- to GND and read voltage on Y+ and Y-.

Then vice versa - Set Y+ to voltage and Y- to GND and read voltage on X+ and X- .

You can do the PEx project setup following way:

1) Add ADC_LDD usin Components Library to your project and configure it in inspector view:

- add four channels on pins that have also GPIO function available and ideally  on the same port (e.g. on MK60FN1M0VLQ15 I found ADC0_SE8, ADC0_SE9, ADC0_SE12, ADC0_SE13 with GPIO PTB0,1,2,3)

- Enable 'Static sample groups' property and create two sample groups, one with channels 0 and 1 (inputs X+ and X-) and second with channels 2 and 3.

- Set 'Conversion time' using the dialog (press the button) to some higher value (for higher precision)

- Set Initialization / Auto initialization to 'yes'.

- switch to the methods tab in the inspector and set ConnectPin method to 'generate code'.

2) Add GPIO_LDD, slect the port from step1 (e.g. PTB) and add four pins same as in ADC.

- Error is reported on the pin rrow (Peripheral is already used) - so select "pin sharing enabled" from the pop-up menu of the pin.

- Set Initial pin direction of each pin to Output.

- Set Initialization / Auto initialization to 'yes'.

- switch to the methods tab in the inspector and set ConnectPin method to 'generate code'.

3) Add Init_GPIO component to initialize electrical features (pull-ups) of the pins. In the properties select the same port device (e.g. PTB).

In Pins group enable the pins you are using (e.g. 0,1,2,3). Enable the pin sharing the same way you did in step 2 othewise error is reported.

For two pins connected to X+ and Y+ that will provide voltage you'll need to enable 'Pull-up resistor' property.

Then in your application you shoul do in a loop :

a) Call GPIO1_ConnectPin function (method of GPIO_LDD component) to connect X+ and X- pins to GPIO peripheral

  1. e.g. GPIO1_ConnectPin( GPIO1_DeviceData, LDD_GPIO_PIN_0 | , LDD_GPIO_PIN_1);

b) Call AD1_ConnectPin function (method of ADC_LDD component) to connect Y+ and Y- pins to ADC peripheral for channels where you have connected Ys, so for example if you have Y+ on channel2 and Y- on channel3:

AD1_ConnectPin(AD1_DeviceData, LDD_ADC_CHANNEL_2_PIN | LDD_ADC_CHANNEL_3_PIN);

c) Call AD1_SelectSampleGroup (AD1_DeviceData, 1) to select sample group 1, i.e. channels for Y+ and Y-

d) Peform ADC measurement by e.g.

//variables declaration

AD1_TResultData MeasuredValues[2];

LDD_TError Error;

...

...

Error = AD1_StartSingleMeasurement(AD1_DeviceData);           /* Start continuous measurement */

while (!AD1_GetMeasurementCompleteStatus(MyADCPtr)) {}; /* Wait for conversion completeness */

Error = AD1_GetMeasuredValues(MyADCPtr, (LDD_TData *)MeasuredValues)

...

note: This code is taken from "Typical usage page" from the ADC_LDD help.

You can also use interrupt enabled and place the code to event handler so you won't need wait for ADC to complete.

e) Now you have two Y values in MeaduredValues array and you can use it to compute Y position.

Then you need to do a-e steps but the other set of pins (X <-> Y) and you'll get X values.

I know this from-scratch-guide is brief and incomplete but is should help you get started with the project.

best regards

Petr Hradsky

Processor Expert Support Team

0 Kudos
624 Views
dporada
Contributor III

Petr,

I tried setting up Static Sample Groups, but when I try to set up the sample list, I get the message "Only 1 samples supported by this HW".

I am currently trying to use the TWR-K60D100M with a K60DN512VMD10 chip.

Any suggestions?

0 Kudos
624 Views
Petr_H
NXP Employee
NXP Employee

Hi,

That's correct, the hardware can sample only one sample at a time.

You need to create more groups with one sample each using the '+' button at 'Sample group list' property.

best regards

Petr Hradsky

Processor Expert Support Team

0 Kudos
624 Views
dporada
Contributor III

Here's what I've got.

0 Kudos
624 Views
Petr_H
NXP Employee
NXP Employee

Oh, I see now, you have a third party component installed. I didn't know this component exists, now I know :-)

( mcuoneclipse/Beans/TouchScreenSensor ) However. I don't know if this component supports Kinetis K60, if you cannot pick the pins there, probably not.

I'll ask the author to check.

best regards

Petr Hradsky

Processor Expert Support Team

625 Views
BlackNight
NXP Employee
NXP Employee

Hi Donald,

ok, that would be me :smileyhappy:.

The truth is: I have not tried (implemented) it for K60.

What you need to do/implement is what Petr explained above: to set up the pins so you can switch between input and output state. This you need to specify as code as below (example for ColdFire JM128 on the TWR-LCD module).

4404_4404.png

If I find some time, I could spend some time to do that thing for the K60 and the TWR-LCD.

0 Kudos
624 Views
dporada
Contributor III

Thanks for the fast response.  How do I remove the modules that are not from Freescale?

0 Kudos
624 Views
BlackNight
NXP Employee
NXP Employee

Hi Donald,

you can right click on the component and then select 'Remove'.

0 Kudos