SAME70 Xplained can't see any signal on USART0 tx pin

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

Goodmorning everybody, i'm kinda a newbie to this microcontroller and after playing around a bit i wanted to make this USART0 to work.

 

After looking at the example provided with Atmel Studio, i wrote this little code here:

 

#include "asf.h"
#include "conf_clock.h"
#include "conf_board.h"
#include "stdio_serial.h"

#define  BUFF_BYTES 1

volatile uint32_t ms=0;
char snd[BUFF_BYTES]= {0b01001101};
volatile uint8_t *data;
volatile uint32_t buffcnt;

void SysTick_Handler(void)
{
 ms++;
}

static void dly(uint32_t dly_ms)
{
 uint32_t cur;

 cur = ms;
 while ((ms - cur) < dly_ms);
}

int main (void)
{
 
 
 sysclk_init();
 board_init();
 
 
 sam_usart_opt_t usart_settings = {9600,US_MR_CHRL_8_BIT,US_MR_PAR_NO,US_MR_NBSTOP_1_BIT,US_MR_CHMODE_NORMAL,0};

 sysclk_enable_peripheral_clock(ID_USART0);

    usart_init_sync_master(USART0, &usart_settings, sysclk_get_peripheral_hz());

 usart_disable_interrupt(USART0, 0xffffffff);

 usart_enable_tx(USART0);
 usart_enable_rx(USART0);

  if (SysTick_Config(sysclk_get_cpu_hz() / 1000)) {
   while (1);
  }

  while (1)
  {
   data= (uint8_t *)&snd;
   buffcnt= BUFF_BYTES;
   while(buffcnt > 0)
   {
    if(0 == usart_write(USART0, *data))
    {
     buffcnt--;
     data++;
    }
    ioport_toggle_pin_level(LED0_GPIO);
    dly(100);
   }

   while(!usart_is_tx_empty(USART0));
   ioport_toggle_pin_level(LED0_GPIO);
   
   dly(1000);

  }

 

}

with various blinking LEDs to see it doesn't get stuck.

 

After i downloaded this to my microcontroller and checked PB1 with an oscilloscope, i wasn't able to see anything going on.

So my question is, do i need to enable something else?

 

Thanks for the help.

Last Edited: Thu. Oct 20, 2016 - 06:29 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Found the problem: there were some missing defines in conf_board.h that i had to add manually, as seen in the one from the usart example.

 

Does anybody know if Atmel Studio is supposed to do that automatically? Or if not, is there a list of all the possible defines you can put there?

 

thanks again.

Last Edited: Fri. Oct 21, 2016 - 07:26 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If it is an example code using USART, then its corresponding definition needs to come automatically.
If doesn't, feel free to add those definitions.
enlightened

Getting used to ASF is not that easy.sad

Silly beans are always silly
:)

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

Harikrishnan911 wrote:

If it is an example code using USART, then its corresponding definition needs to come automatically.
If doesn't, feel free to add those definitions.
enlightened

Getting used to ASF is not that easy.sad

well i started a blank project (with New>Project>GCC C ASF Board Project) and after adding the various libraries with ASF Wizard i thought i was ready to go but that config file needed some additional defines and i wasn't really expecting that.

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

The best way to get started is to checkout a couple of sample codes before creating programs from the scratch.angel

Silly beans are always silly
:)