Giter VIP home page Giter VIP logo

arduinocore-samd's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduinocore-samd's Issues

I2S not working

Hi, I encounter some strange error, when I try to compile a sketch with I2S library it gives me '#error "I2S is not supported on your board!" ', which is a defined error in the .h file of the lib, but I'm using Seeeduino LoRaWAN, which is based on Arduino Zero, and it uses SAMD21D controller, which supports I2S, so I think this is a bug in the code.

Best regards,
Viktor

Arduino tone() function doesn't work with buzzer on Wio Terminal

The Wio Terminal has a buzzer on Arduino pin 12, but it doesn't seem to work with the Arduino tone() function.

For example, uploading the standard example file toneMelody and changing the first parameter of tone() to 12 doesn't produce any sound.

Any suggestions?

USB CDC with flow control

I am trying to use my XIAO to program an ESP32, but esptool.py requires flow control, it is expecting an FTDI chip.
How can I achieve flow control (NAK, etc), to handle large amounts of data, using one of the USB libraries provided with your Arduino lib?

Cannot set interrupt priority correctly for FreeRTOS environment.

CMSIS-Atmel in the current toolchain used by ArduinoCore-samd has a bug which the "atsamd51p19a.h" contains wrong definition of __NVIC_PRIO_BITS.

This causes that applications can not use interrupt priority other than 3, which limits the interrupt usage in applications.

The description of the mechanism is written in my article (Sorry, it's only in Japanese. )

The code to reproduce the problem is here

In order to fix this issue, please change the definition of __NVIC_PRIO_BITS from 2 to 3 in "atsamd51p19a.h" in CMSIS-Atmel

(Updating CMSIS-Atmel also solves the issue, but the structure of CMSIS-Atmel is drastically changed from current version and it's very difficult to update CMSIS-Atmel. So I think just changing __NVIC_PRIO_BITS is the easiest way to solve the issue.)

TCx PWM not working correctly

I'm trying to use pwm() on TC4 (D6 on the Seeduino Xiao), but the duty cycle is being calculated incorrectly in wiring_pwm.cpp line 271:

duty = mapResolution(duty, 10, 16);

For samd51 TCx and TCCx, as well as SAMD21 TCCx, it's using:

duty = map(duty, 0, (1<<PWM_API_RESOLUTION), 0, period);

The result is that the counter (in my case duty period = 2000) is being incorrectly.

I've changed the line to match the others and it works fine for my single use case.

@deanm1278 since this was in your original PR, any idea why TCx is treated differently?

Sketch can't write to Seeeduino XIAO using board package 1.7.3

{runtime.tools.bossac-1.7.0-arduino3.path}/bossac.exe -i -d --port=COM33 -U true -i -e -w -v C:\Users\takashi\AppData\Local\Temp\arduino_build_148209/sketch_may10a.ino.bin -R 
java.io.IOException: Cannot run program "{runtime.tools.bossac-1.7.0-arduino3.path}/bossac.exe": CreateProcess error=2, 指定されたファイルが見つかりません。
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
	at processing.app.helpers.ProcessUtils.exec(ProcessUtils.java:26)
	at cc.arduino.packages.Uploader.executeUploadCommand(Uploader.java:129)
	at cc.arduino.packages.uploaders.SerialUploader.runCommand(SerialUploader.java:383)
	at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:197)
	at cc.arduino.UploaderUtils.upload(UploaderUtils.java:77)
	at processing.app.SketchController.upload(SketchController.java:732)
	at processing.app.SketchController.exportApplet(SketchController.java:703)
	at processing.app.Editor$UploadHandler.run(Editor.java:2047)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: CreateProcess error=2, 指定されたファイルが見つかりません。
	at java.lang.ProcessImpl.create(Native Method)
	at java.lang.ProcessImpl.<init>(ProcessImpl.java:386)
	at java.lang.ProcessImpl.start(ProcessImpl.java:137)
	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
	... 9 more
スケッチの書き込み中にエラーが発生しました

Conflicting IRQ handler betwwen Serial and Wire when used in Slave Mode

When the Wio Terminal is configured as a slave mode, there is a conflicting definition of the IRQ handler:
In variant.h WIRE_IT_HANDLER is defined as SERCOM4 handler whatever the ROLE is. This is used by Wire.cpp included library

In variant.c Depends on ROLE, SERCOM4 is also defined and associated to Serial port1

As a consequence, you can't compile with Wire included when in slave mode.

On seeeduino XIAO analogWrite() to A4 copies to A10 and vice-versa. Same for A5 and A8.

The attached video shows PROGRAM #1 simp[le loop turning on / off each LED using digitalWrite() and PROGRAM #2 using analogWrite().

analogWrite() causes crosstalk between A5 and A8 and also between A4 and A10. Please watch the attached video.

Here’s the schematic for the test setup:

Here’s the code used to demonstrate the XIAO problem.

/*

PROGRAM #1

Demonstrate XIAO digitalWrite()

does NOT crosstalk

*/

void setup() {

for(int i = 1; i <= 10; i++) {

pinMode(i, OUTPUT);

digitalWrite(i, HIGH);

}

}

void loop() {

for(int i = 1; i <= 10; i++) {

digitalWrite(i, LOW);

delay(1000);

digitalWrite(i, HIGH);

}

delay(1000);

}


/*

PROGRAM #2

Demonstrate XIAO analogWrite()

DOES crosstalk

*/

void setup() {

for(int i = 1; i <= 10; i++) {

pinMode(i, OUTPUT);

analogWrite(i, 255);

}

}

void loop() {

for(int i = 1; i <= 10; i++) {

analogWrite(i, 0);
delay(1000);

analogWrite(i, 255);

}

delay(1000);

}

warning: "LITTLE_ENDIAN" redefined

When I built Seeeduino XIAO with v1.7.5, the following warning is displayed.

"C:\\...\\Arduino15\\packages\\Seeeduino\\tools\\arm-none-eabi-gcc\\7-2017q4/bin/arm-none-eabi-g++" -mcpu=cortex-m0plus -mthumb -c -g -Os -std=gnu++11 -ffunction-sections -fdata-sections -fno-threadsafe-statics -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -MMD "-D__SKETCH_NAME__=\"\"\"Blink.ino\"\"\"" -DF_CPU=48000000L -DARDUINO=10812 -DARDUINO_SEEED_XIAO_M0 -DARDUINO_ARCH_SAMD -DARDUINO_SAMD_ZERO -D__SAMD21__ -D__SAMD21G18A__ -DARM_MATH_CM0PLUS -DSEEED_XIAO_M0 -DUSB_VID=0x2886 -DUSB_PID=0x802F -DUSBCON -DUSB_CONFIG_POWER=100 "-DUSB_MANUFACTURER=\"Seeed\"" "-DUSB_PRODUCT=\"Seeed XIAO M0\"" -g "-IC:\\...\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.7.5\\cores\\arduino/TinyUSB" "-IC:\\...\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.7.5\\cores\\arduino/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-IC:\\...\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.7.5\\cores\\arduino/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" -g -DARDUINO_SAMD_ZERO -D__SAMD21__ -D__SAMD21G18A__ -DARM_MATH_CM0PLUS -DSEEED_XIAO_M0 -DUSB_VID=0x2886 -DUSB_PID=0x802F -DUSBCON -DUSB_CONFIG_POWER=100 "-DUSB_MANUFACTURER=\"Seeed\"" "-DUSB_PRODUCT=\"Seeed XIAO M0\"" -g "-IC:\\...\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.7.5\\cores\\arduino/TinyUSB" "-IC:\\...\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.7.5\\cores\\arduino/TinyUSB/Adafruit_TinyUSB_ArduinoCore" "-IC:\\...\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.7.5\\cores\\arduino/TinyUSB/Adafruit_TinyUSB_ArduinoCore/tinyusb/src" "-IC:\\...\\Arduino15\\packages\\Seeeduino\\tools\\CMSIS\\4.5.0/CMSIS/Include/" "-IC:\\...\\Arduino15\\packages\\Seeeduino\\tools\\CMSIS-Atmel\\1.2.0/CMSIS/Device/ATMEL/" "-IC:\\...\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.7.5\\cores\\arduino" "-IC:\\...\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.7.5\\variants\\XIAO_m0" "C:\\...\\Arduino15\\packages\\Seeeduino\\hardware\\samd\\1.7.5\\cores\\arduino\\main.cpp" -o "C:\\...\\Temp\\arduino_build_625793\\core\\main.cpp.o"
In file included from C:\...\Arduino15\packages\Seeeduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21.h:69:0,
                 from C:\...\Arduino15\packages\Seeeduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd.h:105,
                 from C:\...\Arduino15\packages\Seeeduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/sam.h:540,
                 from C:\...\Arduino15\packages\Seeeduino\hardware\samd\1.7.5\cores\arduino\SERCOM.h:22,
                 from C:\...\Arduino15\packages\Seeeduino\hardware\samd\1.7.5\cores\arduino\Uart.h:22,
                 from C:\...\Arduino15\packages\Seeeduino\hardware\samd\1.7.5\cores\arduino\Uart.cpp:19:
C:\...\Arduino15\packages\Seeeduino\tools\CMSIS-Atmel\1.2.0/CMSIS/Device/ATMEL/samd21/include/samd21g18a.h:226:0: warning: "LITTLE_ENDIAN" redefined

 #define LITTLE_ENDIAN          1

Environment

  • Arduino IDE: 1.8.12
  • sketch: 01.Basics / Blink

USB serial (CDC-ACM) to host is stingy with buffers, leads to blocking & bursting

Observed symptoms:

  • When attempting to write from e.g. a Linux host to the (super adorable) Seeeduino XIAO, there is basically 0 buffer. The host write will block until the Arduino code calls Serial.read(). This creates problems such as pyserial/pyserial#653. Having 0 buffer in a serial port system is generally bad for performance.
  • When receiving data, even if the host is attempting to send a significant quantity of data, Serial.read() will return -1 frequently. For example if the host sends "Hello World!", Serial.read() might return 'H', 'e', 'l', -1, 'l', 'o', ' ', 'W', -1, ...
  • Other USB-serial device implementations don't do this.

Discussion:

This code in USBDeviceClass::recv (called from _Serial::read) directly reads data from the USB buffer and only acknowledges the transfer once the code has been read by the app:

if (len && !available(ep)) {

I believe this is why there is a zero-slack channel here, and why Serial.read() gives spurious -1 values as it reaches the end of one buffer and then returns it to the host for more data. Almost every other USB-serial implementation I've seen places some sort of ring buffer in between; USB transfers deposit data into the ring, and the application pulls out of it. That way there is a reasonable amount of "flex" and data can flow smoothly. Is that not something that can be done in this case?

Fixable compiler warnings: math_helper.c

I build with full warnings, and found a few places where small changes can remove compile warnings.

There are 2 compiler warnings coming from math_helper.c:
https://github.com/Seeed-Studio/ArduinoCore-samd/blob/master/cores/arduino/math_helper.c

These 2 warnings are copied below. I can submit a PR if that's the best approach, but wanted to first check if the primary dev team wishes to address these directly.

There are a few correctness issues in these and other conversion functions in math_helper.c that do not generate compile warnings, for values/ranges where perhaps the functions aren't being used today. Where are the functions in this file being used?

--Don

C:\Users\don\AppData\Local\Arduino15\packages\Seeeduino\hardware\samd\1.8.2\cores\arduino\math_helper.c: In function 'arm_compare_fixed_q15':
C:\Users\don\AppData\Local\Arduino15\packages\Seeeduino\hardware\samd\1.8.2\cores\arduino\math_helper.c:175:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(diffCrnt > maxDiff)
^
C:\Users\don\AppData\Local\Arduino15\packages\Seeeduino\hardware\samd\1.8.2\cores\arduino\math_helper.c: In function 'arm_compare_fixed_q31':
C:\Users\don\AppData\Local\Arduino15\packages\Seeeduino\hardware\samd\1.8.2\cores\arduino\math_helper.c:203:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(diffCrnt > maxDiff)
^

Seeeduino 1.8.4 Missing Submodules in Arduino IDE

Hello,

On Arduino IDE, I added Seeeduino but when I tried to use the Seeed Studio XIAO SAMD21 board, the IDE warned of missing header files in libraries. package_seeeduino_boards_index.json link. File link. Downgrading to 1.8.3 bypassed this issue.

I've downloaded the 1.8.4 version from github and folders were missing for the submodules.

Seems like the missing folder contents/headers can be caused by not downloading submodules before upload. Please help update the seeedstudio download link used by board manager download for Seeeduino 1.8.4 with the affected files intact.

Thank you.

For all others seeing this, one option to get your seeeduino working is to clone this repo, use git submodule update --init --recursive and copy the affected files to the library, or directly git clone the offending repositories to the library, or simply downgrade to 1.8.3.

error: 'configCAL_FACTOR' was not declared in this scope

Compiling the wifi sample code gives an error.

Code:
https://wiki.seeedstudio.com/Wio-Terminal-Wi-Fi#scanning-wi-fi-network-example-code

Error message:

C:\Users\takashi\AppData\Local\arduino15\packages\Seeeduino\hardware\samd\1.8.4\libraries\Seeed_Arduino_FreeRTOS\src\error_hooks.cpp: In function 'void vNopDelayMS(long unsigned int)':
C:\Users\takashi\AppData\Local\arduino15\packages\Seeeduino\hardware\samd\1.8.4\libraries\Seeed_Arduino_FreeRTOS\src\error_hooks.cpp:187:39: error: 'configCAL_FACTOR' was not declared in this scope
   unsigned long iterations = millis * configCAL_FACTOR;
                                       ^~~~~~~~~~~~~~~~
C:\Users\takashi\AppData\Local\arduino15\packages\Seeeduino\hardware\samd\1.8.4\libraries\Seeed_Arduino_FreeRTOS\src\error_hooks.cpp:187:39: note: suggested alternative: 'configASSERT'
   unsigned long iterations = millis * configCAL_FACTOR;
                                       ^~~~~~~~~~~~~~~~
                                       configASSERT

Environment:

  • Windows 11 22H2
  • Arduino IDE 2.1.0
  • Seeed SAMD Boards by Seeed Studio 1.8.4

** Libraries:**

  • Seeed Arduino rpcWiFi 1.0.6 ... C:\Users\takashi\Documents\Arduino\libraries\Seeed_Arduino_rpcWiFi
  • Seeed Arduino rpcUnified 2.1.4 ... C:\Users\takashi\Documents\Arduino\libraries\Seeed_Arduino_rpcUnified
  • Seeed Arduino FreeRTOS 10.4.3 ... C:\Users\takashi\AppData\Local\arduino15\packages\Seeeduino\hardware\samd\1.8.4\libraries\Seeed_Arduino_FreeRTOS
  • Seeed Arduino FS 2.1.1 ... C:\Users\takashi\Documents\Arduino\libraries\Seeed_Arduino_FS
  • Seeed_Arduino_mbedtls 3.0.1 ... C:\Users\takashi\Documents\Arduino\libraries\Seeed_Arduino_mbedtls
  • SPI 1.0 ... \Users\takashi\AppData\Local\arduino15\packages\Seeeduino\hardware\samd\1.8.4\libraries\SPI
  • Adafruit Zero DMA Library 1.0.4... C:\Users\takashi\AppData\Local\arduino15\packages\Seeeduino\hardware\samd\1.8.4\libraries\Adafruit_ZeroDMA

Wrong assignment of wakeup bits to external interrupts in EnergySaving library (Seeeduino XIAO)

Inside EnergySaving::enable_eic_wake, there is a switch/case that assigns the input pin number to a WAKEUPENx bit. This function mangles them up in a way that will never wake a Seeeduino XIAO correctly. The WAKEUPENx bits are not mixed up like the function suggests. Waking up from external interrupts start's working as soon as you set the WAKEUPENx bit of the pin used to ::begin() the EnergySaving calls with.

DAC cannot output over 2.2V

Board: Seeeduino XIAO

Code:

void setup() {
  pinMode(DAC0, OUTPUT);
}

void loop() {
  for (int i = 0; i < 1024; ++i)
  {
    analogWrite(DAC0, i);
    delay(1);
  }
}

Output:
image

error: macro "min" passed 3 arguments at stl_algobase.h

I want to use STL.
This code got error.

Board: Seeeduino XIAO

Code:

#include <vector>

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Error message:

In file included from c:\users\takashi\documents\arduinodata\packages\seeeduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\c++\4.8.3\vector:60:0,

                 from C:\Users\takashi\AppData\Local\Temp\arduino_modified_sketch_889764\sketch_apr29a.ino:1:

c:\users\takashi\documents\arduinodata\packages\seeeduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\c++\4.8.3\bits\stl_algobase.h:239:56: error: macro "min" passed 3 arguments, but takes just 2

     min(const _Tp& __a, const _Tp& __b, _Compare __comp)

                                                        ^

c:\users\takashi\documents\arduinodata\packages\seeeduino\tools\arm-none-eabi-gcc\4.8.3-2014q1\arm-none-eabi\include\c++\4.8.3\bits\stl_algobase.h:260:56: error: macro "max" passed 3 arguments, but takes just 2

     max(const _Tp& __a, const _Tp& __b, _Compare __comp)

                                                        ^

exit status 1

tflite with WiFi

Does the new version of the board 1.8.3/1.8.4 support both WiFi and tensorflowlite at the same time?

Unable to read SPI data from slave

Hi,
I'm trying to read the software version from peripheral device as a sanity check upon software startup and faced with very strange issue. I wrote a bare-bone code to check that, and it still has the same issue.

I'm sending a command 0x70 and I expect two bytes of response. Using a logic analyzer I can clearly see the response arrives and values are meaningful. But at the same time what is returned by SPI.transfer() it is zero instead of visible on analyzer values. I look through the library code and found out something like that
https://github.com/Seeed-Studio/ArduinoCore-samd/blob/v1.8.4/cores/arduino/SERCOM.cpp#L362

uint8_t SERCOM::transferDataSPI(uint8_t data)
{
  sercom->SPI.DATA.bit.DATA = data; // Writing data into Data register

  while(sercom->SPI.INTFLAG.bit.RXC == 0); // Waiting Complete Reception

  return sercom->SPI.DATA.bit.DATA;  // Reading data
}

I do not have too much knowledge about that, but I assume it shall work properly. But in reality it doesn't.

Hardware: Seeeduino XAIO SAMD21
Framework version: 1.8.4 installed via Arduino-IDE (GNU/Linux amd64)

image

XIAO SAMD21: Add TX/RX LED On/Off on Arduino IDE menu (like for Seeed Wio Terminal)

Please add the compiler-flag option to enable/disable the Serial TX/RX LEDs also for the XIAO SAMD21 board, like you already did for the Seeed Wio Terminal by accepting commit c68cc757e623a4b30669e7880a4fb0224bbf6169

Add to boards.txt:
seeed_XIAO_m0.menu.txrxled.on=On
seeed_XIAO_m0.menu.txrxled.off=Off
seeed_XIAO_m0.menu.txrxled.on.build.flags.txrxled=-DTXRXLED_ENABLE

Changes in variants\XIAO_m0\variant.h:
#define PIN_LED2 (12u)
#define PIN_LED3 (11u)
#if defined(TXRXLED_ENABLE)
#define PIN_LED_RXL PIN_LED2
#define PIN_LED_TXL PIN_LED3
#endif
Also, assigning the pin-numbers to PIN_LED2/3 (instead of PIN_LED_RXL/TXL) allows the user to reference the individual LED-pins, while still being able to enable/disable the LEDs with the compiler flag.

Please also correct the copy-paste typo in boards.txt for the Wio Lite MG126
from
# Seeed XIAO M0 (SAMD21)
to
# Wio Lite MG126 (SAMD21)

Wio Terminal BCM14/15/18 Mapping

I think BCM14, BCM15, and BCM18 as defined in variant.h under wio_terminal point to the wrong pins. I think they should be 40ul, 41ul, and 52ul respectively, instead of the current values of 41ul, 40ul, and 17ul.

BUILD FAILED for FlashStorage

If you select WioTerminal as the target board, both sample codes included in the FlashStorage library will fail to build.

thank you.

Seeduino LoRaWAN SPI - SD Card Library

It seems that the SPI it's not working properly with the SD Card Library. For Example I run the CardInfo.ino example on another Arduino Clone and it works fine , when I run the same code on Seeeduino LoRaWAN the card can't be initialized same thing happens with other SPI Peripherals for example ADC (mcp3008). Almost two years ago it used to work on Seeeduino LoRaWAN too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.