Reading Mikromedia dsPIC33EP touch panel in Mikrobasic

General discussion on mikroBasic PRO for dsPIC30/33 and PIC24.
Post Reply
Author
Message
jmusselman64
Posts: 31
Joined: 15 May 2018 21:05

Reading Mikromedia dsPIC33EP touch panel in Mikrobasic

#1 Post by jmusselman64 » 10 Jun 2018 06:16

I'm trying to read the X-Y value from the touch panel and send those values out over a serial line.
Sounds simple, but I can't get it to work. All it sends is 0's

I know the serial port works because I can add a 'UART_Write(13) and that shows up in Realterm.

I've looked through the help file and the Examples and still can't figure it out...what am I missing?
Here's the test program:

Code: Select all

' *
' * Project name:
'     Test3.mbpds
' * Generated by:
'     Visual TFT
' * Date of creation
'     6/9/2018
' * Test configuration:
'     MCU:             P33EP512MU810
'                      http://www.microchip.com/wwwproducts/Devices.aspx?product=dsPIC33EP512MU810
'     Dev.Board:       EasyPIC_Fusion_v7_for_dsPIC33EP_9A
'     Oscillator:      140000000 Hz
'     SW:              mikroBasic PRO for dsPIC
'                      http://www.mikroe.com/mikrobasic/dspic/
' *

program Test3_main

  main:
     PPS_Mapping(67, _INPUT, _U1RX)  'set TX/RX pin mapping
     PPS_MAPPING(65, _OUTPUT, _U1TX)

     UART1_Init_Advanced(115200,_UART_8BIT_NOPARITY,_UART_ONE_STOPBIT,_UART_HI_SPEED) 'Initialize serial comm
     UART_Set_Active(@UART1_Read, @UART1_Write, @UART1_Data_Ready, @UART1_Tx_Idle) ' set UART1 active
  
    Start_TP()

    while TRUE
      Check_TP()                  'read touchscreen
      
      uart_write(Xcoord)          'send out X and Y pen position for debug
      delay_us(100)
      uart_write(Ycoord)
      delay_us(100)
      
    wend
  end.

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: Reading Mikromedia dsPIC33EP touch panel in Mikrobasic

#2 Post by filip.grujcic » 11 Jun 2018 11:21

Hi,

Could you zip your project and attach it here? It will be easier for me that way.

Kind regards,
Filip Grujcic

jmusselman64
Posts: 31
Joined: 15 May 2018 21:05

Re: Reading Mikromedia dsPIC33EP touch panel in Mikrobasic

#3 Post by jmusselman64 » 11 Jun 2018 15:05

Thanks Filip...here's the files..:
Attachments
TP_test.zip
(262.95 KiB) Downloaded 96 times

jmusselman64
Posts: 31
Joined: 15 May 2018 21:05

Re: Reading Mikromedia dsPIC33EP touch panel in Mikrobasic

#4 Post by jmusselman64 » 11 Jun 2018 15:15

I should also add that it doesn't do the TP calibration like it does in the example programs.

Jerry

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: Reading Mikromedia dsPIC33EP touch panel in Mikrobasic

#5 Post by filip.grujcic » 11 Jun 2018 16:23

Hi,

Can you try loading a configuration scheme?
Click Project --> Edit Project --> Load Scheme and select one of the P33EP512MU810 schemes and set the appropriate Frequency in Project Settings window.
Filip Grujcic

jmusselman64
Posts: 31
Joined: 15 May 2018 21:05

Re: Reading Mikromedia dsPIC33EP touch panel in Mikrobasic

#6 Post by jmusselman64 » 11 Jun 2018 17:39

OK..I loaded a scheme (mikromedia_for_dsPIC33EP_8MHz.cfgsh) It's the same one the other examples use.

I now get the calibration screen, but after I touch the upper right, it briefly flashes the lower right calibration error, then skips by it before I can touch it..

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: Reading Mikromedia dsPIC33EP touch panel in Mikrobasic

#7 Post by filip.grujcic » 12 Jun 2018 11:23

Hi,

I will attach the project you sent me with some modifications.

Changes I made were:

Loaded the PLL clock scheme and set the frequency to 140 MHz
In Edit Project window, changed PPS config from Allow only one to Allow multiple configurations
Added Unlock_IOLOCK() and Lock_IOLOCK() before and after PPS mapping and
Changed delays in while loop from 100us(terminals cannot process data this fast) to 500 ms

This project should work for you now. Just program it right away.
Another thing, since I can not see how you connected UART pins, please double check the connection to make sure it's working correctly.

Best regards,
Attachments
TP_test_mod.zip
(249.23 KiB) Downloaded 104 times
Filip Grujcic

jmusselman64
Posts: 31
Joined: 15 May 2018 21:05

Re: Reading Mikromedia dsPIC33EP touch panel in Mikrobasic

#8 Post by jmusselman64 » 12 Jun 2018 13:42

Thank you Filip,

I've downloaded, installed, and compiled your changed version.

It now does the TP calibration correctly, and the UART is transmitting (that part was working before).
I still have the same problem...the data it's transmitting doesn't correspond to where I move my finger on the touchscreen.

I'm sending out the value of Xcoord and Ycoord. From what I can see, these are defined in the TP_test_driver.mbas file and are supposed to be the X/Y coordinates of the touch panel input.

What else do I have to do to get those values?

Thanks,
Jerry

jmusselman64
Posts: 31
Joined: 15 May 2018 21:05

Re: Reading Mikromedia dsPIC33EP touch panel in Mikrobasic

#9 Post by jmusselman64 » 12 Jun 2018 15:09

UART1 is assigned to pins RD1/RD3 on the Mikromedia.
I have verified that it words by replacing the

uart_write(Xcoord)

with

uart_write(13) (or any other value)

and I can see it on a logic capture.

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: Reading Mikromedia dsPIC33EP touch panel in Mikrobasic

#10 Post by filip.grujcic » 12 Jun 2018 16:30

Hi,

I made some more changes. I will attach the modified TP_test_main.mbas file, just replace the one in the project's folder with this one(you can back up the old one if you want to).

It should be working correctly now.

Best regards,
Attachments
TP_test_main.zip
(1.03 KiB) Downloaded 87 times
Filip Grujcic

jmusselman64
Posts: 31
Joined: 15 May 2018 21:05

Re: Reading Mikromedia dsPIC33EP touch panel in Mikrobasic

#11 Post by jmusselman64 » 12 Jun 2018 17:01

Thanks Filip... nice addition!

It's working...I'm getting X/Y coordinates on display and output.

So how would I make it output X/Y continuously when finger or stylus on display?

The goal is eventually to send the X/Y coordinates to a moving light (stage light).

User avatar
filip.grujcic
Posts: 822
Joined: 14 May 2018 08:34

Re: Reading Mikromedia dsPIC33EP touch panel in Mikrobasic

#12 Post by filip.grujcic » 18 Jun 2018 12:00

Hello,

I have attached the entire project, you can program it right away to your mikromedia.

Hopefully this time it will work correctly for you :)

Kind regards,
Attachments
TP_test_mod.zip
(251.79 KiB) Downloaded 94 times
Filip Grujcic

Post Reply

Return to “mikroBasic PRO for dsPIC30/33 and PIC24 General”