Serial comms for a 4D display

General discussion on mikroPascal PRO for AVR.
Post Reply
Author
Message
PeterMcLeod
Posts: 14
Joined: 30 Aug 2013 10:07

Serial comms for a 4D display

#1 Post by PeterMcLeod » 31 Oct 2019 20:16

I'm bogged down with what should be a simple task. I want to design a CPU for a couple of machines. It has to collect data from a 4D touch screen and set machine variables. The 4D display uses a simple serial input using Tx and Rx lines only. To ask an object on the screen to change it's status I have to send 6 bytes. I then read one byte return.
This has had me stuck for months now! I originally tried an ARM processor using my Mikropascal for ARM registered compiler. This has been totally unsuccessful even with a lot of support from both 4D and MikroElectronica.
On advise I changed from ARM to AVR and purchased a "Ready for xmega" board. I fortunately have a MikroPascal for AVR registered compiler. In both the ARM and AVR compilers the library functions are very similar so it was not difficult to write the code, I used a single object on the screen and told it to set to mid-scale.

I have trawled the internet but in general the examples given for UART communications either send one byte or text. (I need to send 6 bytes ie 0x01, 0x10, 0x00, 0x00, 0x32, 0x23)
Why is this soooo difficult?
Please don't suggest 4D clicker I've tried that, it's too complicated for this project (and me)!!

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: Serial comms for a 4D display

#2 Post by jovana.medakovic » 01 Nov 2019 12:41

Hello,

If you want to send 6 bytes through the UART communication, you can use for loop which will iterate 6 times and you will send byte by byte.
I believe that I sent you the source code of our 4D display click board, so you can look at our c4d_writeObj function.

Kind regards,
Jovana

PeterMcLeod
Posts: 14
Joined: 30 Aug 2013 10:07

Re: Serial comms for a 4D display

#3 Post by PeterMcLeod » 01 Nov 2019 14:09

Thank you Jovana
Yes I understand I can use a FOR loop and it was part of my test program for the ARM processor. I have tried this with the AVR processor and it is not where the problem lies. You mentioned the source code for the click board but I did not get the attachment. Could you send it again please?
You mentioned the ".. c4d_writeObj function..", can I use this in isolation if I have the library added?
Thanks again
Peter

User avatar
jovana.medakovic
mikroElektronika team
Posts: 986
Joined: 18 Dec 2018 10:36

Re: Serial comms for a 4D display

#4 Post by jovana.medakovic » 01 Nov 2019 14:32

Hi,

In the attachment, you can find the source code.
Yes, you can use this function in isolation, only you have to rename it.

Kind regards,
Jovana
Attachments
library.zip
(47.12 KiB) Downloaded 90 times

Post Reply

Return to “mikroPascal PRO for AVR General”