Ardiuno DUE not work with example on software


hi,

i have bought 1 board ardiuno due , learned more it.
i used examples on ide (version 1.5.6-r2 beta) run it, first time run , have no issue hardware or software.

i run application internal flash memory (write, read, erase) long time using ide (studio) style following example:

code: [select]

#include <stdio.h>
#include <string.h>
#include "sam.h"

////////////////////////////////////////debug code area///////////////////////////////////////////////////////////////////////
/* clock definitions */
#define baud(b) ((systemcoreclock + 8*b)/(16*b))

void ser_init (unsigned long baud_rate) {

  pmc->pmc_wpmr = 0x504d4300;             /* disable write protect            */

  pmc->pmc_pcer0 = ((1ul << id_pioa) |    /* enable pioa clock                */
                    (1ul << id_uart)  );  /* enable uart clock                */

  /* configure uart 115200 baud. */
  pioa->pio_idr    =
    pioa->pio_pudr   =
      pioa->pio_pdr    =  (pio_pa8a_urxd | pio_pa9a_utxd);
  pioa->pio_absr  &= ~(pio_pa8a_urxd | pio_pa9a_utxd);

  uart->uart_cr    = uart_cr_rstrx   | uart_cr_rsttx;
  uart->uart_idr   = 0xffffffff;
  uart->uart_brgr  = baud(baud_rate);
  uart->uart_mr    = (0x4 <<  9);         /* (uart) no parity                 */
  uart->uart_ptcr  = uart_ptcr_rxtdis | uart_ptcr_txtdis;
  uart->uart_cr    = uart_cr_rxen     | uart_cr_txen;
  pmc->pmc_wpmr = 0x504d4301;             /* enable write protect             */
}

/*----------------------------------------------------------------------------
  write character serial port
 *----------------------------------------------------------------------------*/
int ser_putchar (int c) {

  while (!(uart->uart_sr  & uart_sr_txrdy));
  uart->uart_thr = c;
  return (c);
}

/*----------------------------------------------------------------------------
  read character serial port   (blocking read)
 *----------------------------------------------------------------------------*/
int ser_getchar (void) {

  while (!(uart->uart_sr  & uart_sr_rxrdy));
  return (uart->uart_rhr);
}

int main(void){

  wdt->wdt_mr = wdt_mr_wddis; //config watchdog timer
 
  ser_init(9600);

  while(1){
      ser_putchar(ser_getchar());
  };
}


all of above code has written on ide version 1.5.6-r2 beta , run fine on board.

but recently, come coding style on ide version 1.5.6-r2 beta, the board did not work? of example codes followings same issue
code: [select]

void setup() {
  serial.begin(9600);
}

void loop() {
  int sensorvalue = analogread(a0);
  float voltage = sensorvalue * (5.0 / 1023.0);
  serial.println(voltage);
}



after that, come code, board work fine.
currently, have run code (as style) without of example codes ide

could please tell me why have issue?
how fix it?

thanks,
giaolong vietnam

hi giaolong,

it's bit difficult if don't know errors getting. post verbose output during compilation of code doesn't work? go file -> preferences  , click on compilation. regards!

p


Arduino Forum > Products > Arduino Due (Moderator: fabioc84) > Ardiuno DUE not work with example on software


arduino

Comments