It is currently 20 Oct 2017 04:59

All times are UTC + 1 hour




Post new topic Reply to topic  [ 10 posts ] 
Author Message
PostPosted: 08 Aug 2017 15:44 
Offline

Joined: 11 Dec 2016 18:31
Posts: 77
Hi

I try to communicate with the CS5490 chip from Cirrus Logic and my Clicker 2.

The communication use UART protocol and I use UART4. On UART3 I have the UART Click module from MikroE to see the datas "send to"/"receive from" the CS5490.

I have this initialization :
// The CS5490 provides a two-wire, asynchronous, full-duplex UART port.
// The CS5490 UART operates in 8-bit mode, which transmits a total of 10
// bits per byte. Data is transmitted and received LSB first, with one start bit,
// eight data bits, and one stop bit.
UART4_Init_Advanced(600, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, &_GPIO_MODULE_UART4_PA01);


The send/receive methods are :
void CS5490_send(BList *msg, uint8_t size)
{
  int i;
  for (i=0; i<size; i++)
    UART4_Write(msg->tab[i]);
}

uint8_t CS5490_read(uint8_t *size, BList *result)
{
  int i = 0;

  clear_blist(result);

  while (UART4_Data_Ready() == 1)
  {
    result->tab[i++] = (uint8_t)UART4_Read();
  }
  *size = i;
 
  return *size;
}


BList is simply an array of 3 bytes.

I have a problem with the read method : I receive only one byte.
But when I take a look at my signal analyser, I can see that the CS5490 send 3 bytes.
Why I read only 1 byte :(

Complete test program in attachment.

Best regards,
Lionel


Attachments:
simple-test.zip [19.92 KiB]
Downloaded 34 times
Top
 Profile  
 
PostPosted: 08 Aug 2017 23:15 
Offline

Joined: 11 Dec 2016 18:31
Posts: 77
As you can see in this snapshot, in the analyser there are 3 bytes send by the CS5490 and I read only one byte (the first).
Why :?: :(
Maybe the "asynchronous, full-duplex UART port" is not good in my UART4_Init_Advanced :?: :idea:
The data sheet say "The CS5490 UART operates in 8-bit mode, which transmits a total of 10 bits per byte. Data is transmitted and received LSB first, with one start bit, eight data bits , and one stop bit".
In the parameters of UART4_Init_Advanced, how can I specify "one start bit" :?:


Attachments:
Capture.png
Capture.png [ 25.19 KiB | Viewed 737 times ]
Top
 Profile  
 
PostPosted: 09 Aug 2017 17:40 
Offline

Joined: 24 Nov 2005 20:07
Posts: 1141
Location: Colorado, USA
Quote:
how can I specify "one start bit"
You don't. By protocol definition all UART RS-232 type serial data communications begin with one start bit, hence the PIC UART hardware registers and compiler commands do not offer the ability to set this option.


Top
 Profile  
 
PostPosted: 09 Aug 2017 17:49 
Offline
mikroElektronika team
User avatar

Joined: 15 Jan 2016 12:50
Posts: 1448
Hi,

@ Lionel

Unfortunately, I don't have device with CS5490,
therefore I cannot try your code.

But maybe you can consider to use Uart interrupt instead,
you can take a look at example bellow and use it as reference:

https://libstock.mikroe.com/projects/vi ... ck-example

@ Sparky1039

Thank you for useful explanation and for helping our user.

Kind regards,
Lana


Top
 Profile  
 
PostPosted: 11 Aug 2017 09:42 
Offline

Joined: 11 Dec 2016 18:31
Posts: 77
Hi

Thanks Lana : it's working with interrupt :!: :D
It's a little more complicated because I need to count the byte received, but it work :D :D

@Sparky1039 : This is not PIC, but ARM

Thanks again
Lionel


Top
 Profile  
 
PostPosted: 11 Aug 2017 21:10 
Offline

Joined: 24 Nov 2005 20:07
Posts: 1141
Location: Colorado, USA
Quote:
This is not PIC, but ARM
What difference does this make? Asynchronous serial communication protocol is independent of the processor platform, and always begins with one and only one start bit.


Top
 Profile  
 
PostPosted: 12 Aug 2017 08:41 
Offline

Joined: 11 Dec 2016 18:31
Posts: 77
Hi,

I don't know. Some code work for PIC and not for others chips so my precision.
But if you say that the protocol is independent, it's OK :D

Thanks,
Lionel


Top
 Profile  
 
PostPosted: 12 Aug 2017 17:55 
Offline

Joined: 11 Dec 2016 18:31
Posts: 77
Hi

New question on the same subject :D

I notice that if I add a quick timer (100 ms) on my program, the UART with interrupt does not work :(
With a timer of 1 s, it is quite good : only a few data are lost.
I try to add this function :
NVIC_SetIntPriority(IVT_INT_UART4,0);

But it does not change anything :(

An idea :?:

Best regards,
Lionel

Note : I found a "bad" solution adding NVIC_SetIntPriority(IVT_INT_TIM2,1); in the Timer but the code is slow now :(


Top
 Profile  
 
PostPosted: 14 Aug 2017 10:05 
Offline

Joined: 11 Dec 2016 18:31
Posts: 77
After test several solutions, finally I think that my problem is that my UART communication is to slow :!:
So I try to change the Baud rate but with no success : see my new post

Regards,
Lionel


Top
 Profile  
 
PostPosted: 15 Aug 2017 17:07 
Offline
mikroElektronika team
User avatar

Joined: 15 Jan 2016 12:50
Posts: 1448
Hi Lionel,

I have answered you here:

viewtopic.php?f=178&t=70675&p=285087#p285087

Kind regards,
Lana


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: