Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Porting usart for receiving data

porting np2 usart

  • Please log in to reply
No replies to this topic

#1 jiwonoh

jiwonoh

    Advanced Member

  • Members
  • PipPipPip
  • 42 posts

Posted 12 August 2014 - 01:59 AM

Hi, all

I'm trying to solve stream-broken in usart through MF.

Through usart bus, 21760 bytes as speed of 250kbps should be transferred. When I tested with netduino based PK with large buffer(I modified RxQueue to receive all data), sometimes data is missing. Every time the index of missing is changing, so I think it is not related with logic in C# app.

Below is a part of netduino source related with USART.

 

void STM32_USART_Handle_RX_IRQ (int ComPortNum, USART_TypeDef* uart)
{   
	INTERRUPT_START;   
	char c = (char)(uart->DR); // read RX data   
	USART_AddCharToRxBuffer(ComPortNum, c);   
	Events_Set(SYSTEM_EVENT_FLAG_COM_IN);   
	INTERRUPT_END;
}
 

I thought it is related with AddCharToRxBuffer, so I used this test code in Keil with debugger.
(the length of data is fixed, so I used MAX_STRLEN for checking stream is finished)

 

 

?

 

void STM32_USART_Handle_RX_IRQ (int ComPortNum, USART_TypeDef* uart)
{
	INTERRUPT_START;
	if(cnt < MAX_STRLEN)
	{
		char c = (char)(uart->DR); // read RX data
		received_string[cnt] = (char)(uart->DR);
		cnt++;
	}
	else
	{
		for(int i = 0; i < MAX_STRLEN; i++)
		{
			USART_AddCharToRxBuffer(ComPortNum, received_string[i]);
			Events_Set(SYSTEM_EVENT_FLAG_COM_IN);
		}
		cnt = 0;
	}
	INTERRUPT_END;
}

When I confirm the data in received_string array while PC is hang in else condition, the data is different with original one.

Now I am suppose it is timing issue.
- Usart Interrupt Clock or
- Thread/Timer issue related with other core function or

I'm not expert in native and embedded, so I'm checking every module one by one. I wonder which part can be related with this issue.


P.S. I tested also native example, and it works. So this is not hardware problem.

 

 

Jiwon

 







Also tagged with one or more of these keywords: porting, np2, usart

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.