Go Down

Topic: Ardiuno DUE not work with example on software (Read 285 times) previous topic - next topic

GiaoLong

May 11, 2015, 10:04 am Last Edit: May 11, 2015, 10:10 am by GiaoLong
Hi,

I have bought 1 board ardiuno DUE and learned more from it.
I used examples on the IDE (version 1.5.6-r2 BETA) to run it, first time it run very good and have no issue about hardware or software.

I run my application about internal flash memory (write, read, erase) for a long time by using the IDE (studio) with my style as 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 for 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 to Serial Port
 *----------------------------------------------------------------------------*/
int SER_PutChar (int c) {

  while (!(UART->UART_SR  & UART_SR_TXRDY));
  UART->UART_THR = c;
  return (c);
}

/*----------------------------------------------------------------------------
  Read character from 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 for 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 and run fine on the board.

But recently, I come back with coding as your style also on IDE version 1.5.6-r2 BETA, the board did not work? all of example codes as followings are 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, I come back with my code, the board work fine.
Currently, It have just run with my code (as my style) without all of example codes from IDE

Could you please tell me why have this issue?
How to fix it?

Thanks,
GiaoLong from VietNam

Palliser

Hi GiaoLong,

It's a bit difficult to help you if we don't know what errors you are getting. Could you post the verbose output during the compilation of the code that doesn't work? Go to File -> Preferences  and do click on compilation. Regards!

p

GiaoLong

#2
May 13, 2015, 04:35 am Last Edit: May 13, 2015, 04:42 am by GiaoLong
Hi Palliser,

The log file which you want as attached file

And here is capture of my code in IDE:


My issue is: the board did not work again with any example code from IDE after I used my code.
Code: [Select]

nclude <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 for 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 to Serial Port
 *----------------------------------------------------------------------------*/
int SER_PutChar (int c) {

  while (!(UART->UART_SR  & UART_SR_TXRDY));
  UART->UART_THR = c;
  return (c);
}

/*----------------------------------------------------------------------------
  Read character from 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 for watchdog timer
 
  SER_Init(9600);

  while(1){
      SER_PutChar(SER_GetChar());
  };
}

eugenio412

Did you try with a non beta Arduino IDE? a beta software might be very buggy sometimes

Palliser

GiaoLong,

Are you getting errors when you are trying to upload your sketch? Your attached file only shows the compilation of your code (verify). Try pressing CRTL+R.

p

GiaoLong

Thanks for your answer eugenio412,

But I can not use another IDE version, because Ardiuno DUE board just been supported by this version.
Could you please help me find another?



GiaoLong

#6
May 14, 2015, 12:22 pm Last Edit: May 14, 2015, 01:12 pm by GiaoLong
GiaoLong,

Are you getting errors when you are trying to upload your sketch? Your attached file only shows the compilation of your code (verify). Try pressing CRTL+R.

p
Thanks for your feedback Palliser, I can not show to you about error, because, all of things are fine: verify code, upload code to board. But just 1 problem: software does not work with board.

log file of upload as attached file.

May be my code impact on internal flash of the chip, so start address of flash is modified??
Unfortunately, the start address of flash used in startup code of IDE has been erased when my code run?

eugenio412

Thanks for your answer eugenio412,

But I can not use another IDE version, because Ardiuno DUE board just been supported by this version.
Could you please help me find another?



actually i have a Due and I use the last IDE available, the 1.6.4, i'm sure it's working, try with that

GiaoLong

actually i have a Due and I use the last IDE available, the 1.6.4, i'm sure it's working, try with that
Thanks for your suggestion, I will test again with it. and then feedback here.

GiaoLong

actually i have a Due and I use the last IDE available, the 1.6.4, i'm sure it's working, try with that
HI eugenio412,

How are you get Ardiuno DUE board from IDE 1.6.4?
I dont see it on this.


Thanks,
GiaoLong

Palliser

How are you get Ardiuno DUE board from IDE 1.6.4?
I dont see it on this.

You need to use the Tools->Boards Manager in order to load the Arduino Due package.

p

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy