EXT1 header UART is not working when EDBG port is working

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

     I'm working and learning basic controls in samd21 xplained pro In that, the USART callback example is the one i tried for EDBG ort. and i would like to go for USART in EXT1 or 2 or 3. but, whatever i properly do a configuration. the port is not getting and data from PC as well as not sendng any any data. i replaced properly all the EDBG related macros to EXT1 macros.

    some people has already discussed about this. there some are telling use I2C pins in place of UART. i know sure that won't work. Some have told to add the enable transmitter and receiver line using this sort of EXT1_UART_SERCOM_DMAC_ID_TX. i did even this also. not there is no improvement.

    Can anyone give suggestions. What i nedd to change. bcoz it is working well and good in EDBG port.

This topic has a solution.

prithivi

Last Edited: Tue. Sep 26, 2017 - 06:12 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Prithivipandya wrote:
i properly do a configuration
Please post your code (at least a minimal amount that shows what you are doing), it is not possible to verify that you have everything set correctly without seeing exactly what you are doing...

David (aka frog_jr)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How are you connecting to the PC?

 

Have you checked with an oscilloscope (or logic analyser) to see if anything is happening on the pins?

 

As frog_jr says, we cannot possibly debug your code without seeing it - can we?!

 

How to properly post code: http://www.avrfreaks.net/comment...

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Prithivipandya wrote:
i replaced properly all the EDBG related macros to EXT1 macros

Most likely, you missed something.

It only takes one little detail ...

 

One thing you could try is to step through the EDBG (working) code, noting every configuration that it makes.

 

Then step through the EXTI (not working) version - and see if you can spot any configurations that you've missed ...

 

 

Last Edited: Fri. Sep 22, 2017 - 01:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is my code

I connected pin(13,14) of EXT1 in samd21 with TTL to USB connector(3.3 V logic) i checked by swapping the pins also but it is not working

#include <asf.h>
#include <stdio.h>
#include <string.h>

#define MAX_RX_BUFFER_LENGTH   5

void usart_read_callback	(struct usart_module *const usart_module);
void usart_write_callback	(struct usart_module *const usart_module);

void configure_usart			(void);
void configure_usart_callbacks	(void);

struct usart_module usart_instance;
volatile uint8_t rx_buffer[MAX_RX_BUFFER_LENGTH];

void usart_read_callback(struct usart_module *const usart_module)
{
	usart_write_buffer_job(&usart_instance,	(uint8_t *)rx_buffer, MAX_RX_BUFFER_LENGTH);
}

void usart_write_callback(struct usart_module *const usart_module)
{
	port_pin_toggle_output_level(LED_0_PIN);
}

void configure_usart(void)
{
	struct usart_config config_usart;
	usart_get_config_defaults(&config_usart);

	config_usart.baudrate			= 115200;
	config_usart.mux_setting		= EXT1_UART_SERCOM_MUX_SETTING;
	config_usart.pinmux_pad0		= EXT1_UART_SERCOM_PINMUX_PAD0;
	config_usart.pinmux_pad1		= EXT1_UART_SERCOM_PINMUX_PAD1;
	config_usart.pinmux_pad2		= EXT1_UART_SERCOM_PINMUX_PAD2;
	config_usart.pinmux_pad3		= EXT1_UART_SERCOM_PINMUX_PAD3;
	config_usart.transmitter_enable = EXT1_UART_SERCOM_DMAC_ID_TX;
	config_usart.receiver_enable    = EXT1_UART_SERCOM_DMAC_ID_RX;

	while (usart_init(&usart_instance, EXT1_UART_MODULE, &config_usart) != STATUS_OK) { }

	usart_enable(&usart_instance);
}

void configure_usart_callbacks(void)
{
	usart_register_callback (&usart_instance, usart_write_callback, USART_CALLBACK_BUFFER_TRANSMITTED);
	usart_register_callback (&usart_instance, usart_read_callback, USART_CALLBACK_BUFFER_RECEIVED);
	usart_enable_callback   (&usart_instance, USART_CALLBACK_BUFFER_TRANSMITTED);
	usart_enable_callback   (&usart_instance, USART_CALLBACK_BUFFER_RECEIVED);
}
int main(void)
{
	system_init			();
	configure_usart			();
	configure_usart_callbacks	();
	system_interrupt_enable_global	();
	uint8_t string[] = "Hello World!\r\n";
	usart_write_buffer_wait(&usart_instance, string, sizeof(string));
	for(;;)
	{
		usart_read_buffer_job(&usart_instance, (uint8_t *)rx_buffer, MAX_RX_BUFFER_LENGTH);
	}
}

 

prithivi

Last Edited: Sat. Sep 23, 2017 - 08:53 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

Prithivipandya wrote:
i replaced properly all the EDBG related macros to EXT1 macros

Most likely, you missed something.

It only takes one little detail ...

 

One thing you could try is to step through the EDBG (working) code, noting every configuration that it makes.

 

Then step through the EXTI (not working) version - and see if you can spot any configurations that you've missed ...

 

 

Actually this code itself i just edited from the EDBG working code example only. That's why i didn't do that comparision.

prithivi

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Prithivipandya wrote:
Here is my code

You didn't follow the instructions on how to post code - did you?

 

See #3.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Prithivipandya wrote:
i just edited from the EDBG working code example only.

But that hasn't worked - has it?

That's why i didn't do that comparision.

So do it now!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

Prithivipandya wrote:
Here is my code

You didn't follow the instructions on how to post code - did you?

 

See #3.

Oh i forgot it. it's okay. now i maintained properly.

the only difference i find in between two source codes are only the difference in configure usart() function as i posted below

void configure_usart(void)
{
	struct usart_config config_usart;
	usart_get_config_defaults(&config_usart);

	config_usart.baudrate			= 115200;
	config_usart.mux_setting		= EXT1_UART_SERCOM_MUX_SETTING;
	config_usart.pinmux_pad0		= EXT1_UART_SERCOM_PINMUX_PAD0;
	config_usart.pinmux_pad1		= EXT1_UART_SERCOM_PINMUX_PAD1;
	config_usart.pinmux_pad2		= EXT1_UART_SERCOM_PINMUX_PAD2;
	config_usart.pinmux_pad3		= EXT1_UART_SERCOM_PINMUX_PAD3;
	config_usart.transmitter_enable = EXT1_UART_SERCOM_DMAC_ID_TX;
	config_usart.receiver_enable    = EXT1_UART_SERCOM_DMAC_ID_RX;

	while (usart_init(&usart_instance, EXT1_UART_MODULE, &config_usart) != STATUS_OK) { }

	usart_enable(&usart_instance);
}

and the working EDBG port code will look like this:

void configure_usart(void)
{
	struct usart_config config_usart;
	usart_get_config_defaults(&config_usart);

	config_usart.baudrate			= 115200;
	config_usart.mux_setting		= EDBG_CDC_SERCOM_MUX_SETTING;
	config_usart.pinmux_pad0		= EDBG_CDC_SERCOM_PINMUX_PAD0;
	config_usart.pinmux_pad1		= EDBG_CDC_SERCOM_PINMUX_PAD1;
	config_usart.pinmux_pad2		= EDBG_CDC_SERCOM_PINMUX_PAD2;
	config_usart.pinmux_pad3		= EDBG_CDC_SERCOM_PINMUX_PAD3;
	config_usart.transmitter_enable = EDBG_CDC_SERCOM_DMAC_ID_TX;
	config_usart.receiver_enable    = EDBG_CDC_SERCOM_DMAC_ID_RX;

	while (usart_init(&usart_instance, EDBG_CDC_MODULE, &config_usart) != STATUS_OK) { }

	usart_enable(&usart_instance);
}

Even the Hello world print also not working with that EXT1 code.

prithivi

Last Edited: Sat. Sep 23, 2017 - 08:55 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well it works fine for me using ASF 3.34.2. Sorry for asking but did you connect GND also?

	config_usart.transmitter_enable = EXT1_UART_SERCOM_DMAC_ID_TX;
	config_usart.receiver_enable    = EXT1_UART_SERCOM_DMAC_ID_RX;

Makes no sense, transmitter_enable and receiver_enable are bool values and default to true from usart_get_config_defaults, just by luck they get set true with the above also.

/Lars

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks for the support it was the hardware fault created TTL to USB convertor.. I replaced a new Convertor that works fine for me. 

Thank you so much for your patience Lajon and awnell

 

prithivi