Is there a beginners tutorial available for PIC32?

General discussion on Visual TFT Software.
Post Reply
Author
Message
ISL_Dave
Posts: 695
Joined: 29 Jul 2009 09:48
Location: Sheffield

Is there a beginners tutorial available for PIC32?

#1 Post by ISL_Dave » 12 Jun 2019 18:55

I have spent weeks (on and off) trying to get my new TFT/MikroC for PIC32/EasyPIC Fusion V7 system to display something on the screen but the screen is permanently white.

I have started with a new TFT project, switched to TFT (F12) and placed a button saying "PressMe".
I have also tried to display a 320x240 image.

I have pressed to generate Visual TFT code and can see the functions in the driver.c file.

I can see my main code has included a call to the Start_TP() function and placed the Check_TP() function in a forever while(1) loop.

I have placed some code to make the buzzer produce sound to check as the Start_TP() function progresses and can see the InitializeTouchPanel() function sets the ADC as the RB2 and RB3 LED's vary in intensity depending on where I touch the screen after it has been called.
If the LEDs for PortB are off, it waits for me to touch the screen twice to continue but doesn't if the LED's are ON (still nothing ever gets displayed).

I can make the buzzer sound and an LED flash in the While(1) loop.

I wrongly assumed that in the Start_TP() function that it would do something as it has commands like TFT_Fill_Screen(0); which does nothing and a call to the calibrate() function which seems to do something as it waits for the screen touching twice but doesn't display anything.

I have tried various commands like TFT_Dot(100, 100, CL_GREEN); after the Check_TP(); function call but still nothing happens.

The hardware is clearly working because one of the example files produces a display but I cannot figure out how it works as it doesn't seem to use visual TFT.

Any suggestions would be welcome.

hexreader
Posts: 1785
Joined: 27 Jun 2010 12:07
Location: England

Re: Is there a beginners tutorial available for PIC32?

#2 Post by hexreader » 12 Jun 2019 20:12

Which PIC32 are you using?

Which TFT display do you have? The older "9" display with silver surround, or the newer "9A" display with black surround?
Start every day with a smile...... (get it over with) :)

ISL_Dave
Posts: 695
Joined: 29 Jul 2009 09:48
Location: Sheffield

Re: Is there a beginners tutorial available for PIC32?

#3 Post by ISL_Dave » 12 Jun 2019 21:53

Hi, thanks for replying. Its a PIC32MX460F512L.

The screen is only about a month old but I don't think its either of what you suggest and came as part of the EasyPIC Fusion v7

It has a black border, says Multi-Inno and 0283QT-8 and when I look at the http://www.multi-inno.com web site, I can see a MI0283QT-8 (which I think I have) and a MI0283QT-9A (which is what you may be referring to).
MI0283QT-8.jpg
MI0283QT-8.jpg (105.36 KiB) Viewed 3208 times
I have looked and both apparently use the same ILI9341V LCD Driver and so would hope they work the same although the -8 version says the interface is 16-bit CPU and the -9A says CPU, RGB and SPI although from the way it is wired and from the code, I deduce it uses the data bus on port D so isn't using RGB or SPI anyway.

Cheers,
Dave
Last edited by ISL_Dave on 12 Jun 2019 22:11, edited 1 time in total.

hexreader
Posts: 1785
Joined: 27 Jun 2010 12:07
Location: England

Re: Is there a beginners tutorial available for PIC32?

#4 Post by hexreader » 12 Jun 2019 22:05

I do not own that particular PIC PIM, so cannot provide any tested examples for you.

... and yes, that is the 9A display. When you download examples, be sure to use the examples in the 9A folder in preference to those in the main folder.

A forum search came up with this result:
viewtopic.php?f=160&t=74573&p=298531&hi ... al#p298531

Not tried any of those links.

I do find that I sometimes struggle with importing older projects.
Start every day with a smile...... (get it over with) :)

hexreader
Posts: 1785
Joined: 27 Jun 2010 12:07
Location: England

Re: Is there a beginners tutorial available for PIC32?

#5 Post by hexreader » 12 Jun 2019 22:42

Don't know if it helps in anyway, but take it or leave it...

I created a super simple project as attached. Similar project works for PIC32MX795F512L, so hopefully I correctly made it for your PIC, but cannot test it.

What I did was:
1) New project - VTFT project - fusion for 9A
2) Select processor
3) put a single button on screen
4) added an "on-click" event with random name
5) put a single instruction LATA = ~LATA; in the empty on-click function
6) put an initialisation line TRISA = 0; as the first instruction in the main function in the main file
7) turn on PORTA LEDs
8 ) programmed to board

I see that the example programs seem to be already set for your setup, as long as you go to the 9A directory where needed
Attachments
forum.zip
(272.31 KiB) Downloaded 84 times
Start every day with a smile...... (get it over with) :)

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

Re: Is there a beginners tutorial available for PIC32?

#6 Post by filip.grujcic » 13 Jun 2019 09:51

Hello,

Make sure your configuration bits are set correctly in project settings (Ctrl + Shift + E). You can load some existing configuration schemes for your MCU by clicking on the Load Scheme button and choosing the appropriate one.

Second thing to check would be your TFT_Init function.
As hexreader pointed out, if you have a TFT display with black border, you have to use the TFT_Init_ILI9341_8bit() function.

Kind regards,
Filip Grujcic

ISL_Dave
Posts: 695
Joined: 29 Jul 2009 09:48
Location: Sheffield

Re: Is there a beginners tutorial available for PIC3

#7 Post by ISL_Dave » 13 Jun 2019 10:57

Wow, thanks guys you were both really helpful.

It seems I wasn't really doing anything wrong all this time apart from when I created a new project, I didn't consider that the development system that it pre-filled in for me which was the correct development system may have two versions so I never clicked to see what other options were available.

Also, I would never have guessed what the _9A variant meant with me being a noob and my TFT saying MIQ02830T-8.

Also, I cannot find any 9A TFT examples folder on my PC. Maybe there is something else I have not installed?
The only TFT examples I can find are:
\VTFT\EasyPIC Fusion v7_FT800\
\VTFT\mikromedia for PIC32\
\VTFT\mikromedia Plus for PIC32MX7
\Development Systems\EasyPIC Fusion v7\TFT\TFT_demo_main <<THIS IS THE ONE THAT MADE THE DISPLAY WORK

I am eternally grateful and should have asked for help sooner.

I just need the compiler to stop crashing as its a worry that I haven't really started using it and it seems unstable.
I have created a new simple project to make the display orange and simply gone to add a pre-prepared 320x240 image and rename when boom, it crashed.
I sent bug report before restarting it and was able to do what I was trying to do previously and display our company logo.

Kind Regards,
Dave

ISL_Dave
Posts: 695
Joined: 29 Jul 2009 09:48
Location: Sheffield

Re: Is there a beginners tutorial available for PIC32?

#8 Post by ISL_Dave » 13 Jun 2019 11:05

One more thing as I am learning how it works.

When I start my micro, it now enters the screen calibration every time.
Where do the calibration results get stored?

I would like to store them in non-volatile memory so I do not have to call the calibrate function every time but can add an option to enter calibration if necessary.

What puzzles me is the code that is generated does not use the TouchPanel library in Library Manager and so I cannot see what the "TP_TFT_Calibrate_Min();" actually does.

Thanks,
Dave

hexreader
Posts: 1785
Joined: 27 Jun 2010 12:07
Location: England

Re: Is there a beginners tutorial available for PIC32?

#9 Post by hexreader » 13 Jun 2019 12:55

Download the example programs for EasyPIC Fusion v7 board. That is where the 9A folder is located.

Can't help with image... not tried my own

To prevent screen calibration:
1) project
2) edit project
3) select VTFT settings tab
4) select touch panel tab
5) choose "preset" radio button
6) (not related but while here) the "init code" box is actually the correct place to put your initialisation code (or a call to your own function in "user code" area of VTFT code. In my example TRISA = 0; Just after main declaration is not the correct place for init code - I cheated

I find default calibration values to work reliably.

Keep asking questions and searching old posts for help. Much of this is non-intuitive
Start every day with a smile...... (get it over with) :)

ISL_Dave
Posts: 695
Joined: 29 Jul 2009 09:48
Location: Sheffield

Re: Is there a beginners tutorial available for PIC32?

#10 Post by ISL_Dave » 13 Jun 2019 15:03

Thanks, I have already learned more in the last few hours than in the last few weeks :lol:

I suspect the touch screen calibration may be beneficial for something that may require precision and utilize a stylus (for drawing or similar) but in my case, a chunky finger selecting one of three buttons may work fine with default values.
I don't want to develop something that requires a stylus as there is nothing more annoying than when it gets lost.

I would never have thought of looking in the project settings for all this but knew it would be somewhere as every time I removed the calibration() function, it came back :roll: .

So the init_code section in the TFT tab is where I place ALL my micro init code?
This is normally quite large as I set all ports, SPI, I2C, enable sound, UART etc.

I will figure it out but I have done what you say and can see the code has updated in the driver.c file as it now sets the calibration constants but somewhere it is still calling the calibration function.

hexreader
Posts: 1785
Joined: 27 Jun 2010 12:07
Location: England

Re: Is there a beginners tutorial available for PIC32?

#11 Post by hexreader » 13 Jun 2019 15:17

ISL_Dave wrote: So the init_code section in the TFT tab is where I place ALL my micro init code?
Call a function that does all of your initialisation.

The function (name of your choosing) can sit in the user-code section.

Putting your own code in the wrong places can cause it to be completely lost on next compilation.

All this advice is from failing memory of old VTFT versions on differing compilers. Things may have changed over time.

... but you seem to be getting the general idea....
Start every day with a smile...... (get it over with) :)

ISL_Dave
Posts: 695
Joined: 29 Jul 2009 09:48
Location: Sheffield

Re: Is there a beginners tutorial available for PIC32?

#12 Post by ISL_Dave » 17 Jun 2019 13:42

I thought I was getting the idea but as things were starting to clear up last week, I now find I am more confused than ever.

I have downloaded the example files for the EasyPIC Fusion v7 but most of them don't work and still produce a blank screen, even after I select the MX460 versions and use the _9A driver.
There best one I can see isn't a TFT project and I am now thinking it is easier to use the TFT without using the TFT compiler.

I have created a screen but have spent ages trying to find out how to change any of the text labels on the screen. Probably doesn't help as I keep thinking of how I do it in VB.

It seems that I may have to overwrite the old text with the same text after setting the colour the same as the background but I cannot get anything displayed outside the changes I do within Visual TFT designer.

I don't understand the project structure as previously I was able to put a sound_play function in the main() function just to indicate where the code is running but now find that no matter what I place in the main.c and events_code.c files, they are ignored (its like my project is using different copies of the files).

i.e. I can delete both files and replace with garbage and the project compiles fine and runs like it did previously.

Closing and re-opening the project just opens my files with garbage and I cannot find where the actual files it is using are located.

It did however spot me putting rubbish in the driver.c file even though it doesn't seem to do what is in the driver.c file I have in front of me.

Also, I still find that when I edit the Touchpanel tab within the project (i.e. put in a call to some function within the Init Code: section or set the calibration to Preset), the changes are reflected in the driver.c file BUT again it is like it is using/compiling a different file as it doesn't call the function and still does a manual calibration.

i.e. These are snippets of the driver.c file and auto generated by making changes within the edit project section but both display the manual calibration function

Code: Select all

void Start_TP() {
  Init_MCU();

  InitializeTouchPanel();

  Delay_ms(1000);
  TFT_Fill_Screen(0);
  Calibrate();
  TFT_Fill_Screen(0);

  InitializeObjects();
  display_width = Splash.Width;
  display_height = Splash.Height;
  DrawScreen(&Splash);
}
and

Code: Select all

void Start_TP() {
  Init_MCU();

  InitializeTouchPanel();

  // You can get calibration constants using touch panel calibration example
  TP_TFT_Set_Calibration_Consts(75, 907, 77, 915);    // Set calibration constants

  InitializeObjects();
  display_width = Splash.Width;
  display_height = Splash.Height;
  DrawScreen(&Splash);
}
I have checked the files listed in Project Manager and the only 4 files are the same ones I am looking at.

All I want to do is display an image with text and then change that text. I will then go further and using the RTC5 click board display the time on the screen but as it stands I cannot even make an LED flash as I cannot find where to place any portion of code that will execute.

Post Reply

Return to “Visual TFT General”