diff --git a/cores/arduino/validation/build_as6/test.atsuo b/cores/arduino/validation/build_as6/test.atsuo index 26b524b33b54fad372b5784431c9893881c36c82..3a782617a392448667aa0aa645718027d4129c0f 100644 Binary files a/cores/arduino/validation/build_as6/test.atsuo and b/cores/arduino/validation/build_as6/test.atsuo differ diff --git a/cores/arduino/validation/build_as6/test.cppproj b/cores/arduino/validation/build_as6/test.cppproj index fdb1f72b4e591e41124afbebf41c504449099484..a2a5d05e8828b1aba6d757e8bb8003979f53f2ae 100644 --- a/cores/arduino/validation/build_as6/test.cppproj +++ b/cores/arduino/validation/build_as6/test.cppproj @@ -26,14 +26,14 @@ <BootSegment>2</BootSegment> <eraseonlaunchrule>1</eraseonlaunchrule> <AsfFrameworkConfig> - <framework-data xmlns=""> + <framework-data> <options /> <configurations /> <files /> <documentation help="" /> <offline-documentation help="" /> <dependencies> - <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.17.0" /> + <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.6.0" /> </dependencies> </framework-data> </AsfFrameworkConfig> @@ -53,13 +53,14 @@ <com_atmel_avrdbg_tool_edbg> <ToolOptions> <InterfaceProperties> + <JtagEnableExtResetOnStartSession>false</JtagEnableExtResetOnStartSession> <SwdClock>4000000</SwdClock> </InterfaceProperties> <InterfaceName>SWD</InterfaceName> </ToolOptions> <ToolType>com.atmel.avrdbg.tool.edbg</ToolType> - <ToolNumber>ATML2320021800000010</ToolNumber> - <ToolName>EDBG</ToolName> + <ToolNumber>ATML2320021800000009</ToolNumber> + <ToolName>XPRO-EDBG</ToolName> </com_atmel_avrdbg_tool_edbg> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)' == 'Release' "> @@ -131,89 +132,87 @@ <PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <ToolchainSettings> <ArmGccCpp> - <armgcc.common.outputfiles.hex>True</armgcc.common.outputfiles.hex> - <armgcc.common.outputfiles.lss>True</armgcc.common.outputfiles.lss> - <armgcc.common.outputfiles.eep>True</armgcc.common.outputfiles.eep> - <armgcc.common.outputfiles.bin>True</armgcc.common.outputfiles.bin> - <armgcc.common.outputfiles.srec>True</armgcc.common.outputfiles.srec> - <armgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</armgcc.compiler.general.ChangeDefaultCharTypeUnsigned> - <armgcc.compiler.symbols.DefSymbols> - <ListValues> - <Value>DEBUG</Value> - </ListValues> - </armgcc.compiler.symbols.DefSymbols> - <armgcc.compiler.directories.DefaultIncludePath>False</armgcc.compiler.directories.DefaultIncludePath> - <armgcc.compiler.directories.IncludePaths> - <ListValues> - <Value>../../../../../../../tools/CMSIS/Device/ATMEL</Value> - <Value>../../../../../../../tools/CMSIS/CMSIS/Include</Value> - <Value>../../..</Value> - <Value>../../../USB</Value> - <Value>../../../../../variants/arduino_zero</Value> - <Value>../../../../../libraries/SPI</Value> - <Value>../../../../../libraries/Wire</Value> - </ListValues> - </armgcc.compiler.directories.IncludePaths> - <armgcc.compiler.optimization.level>Optimize (-O1)</armgcc.compiler.optimization.level> - <armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection> - <armgcc.compiler.optimization.PrepareDataForGarbageCollection>True</armgcc.compiler.optimization.PrepareDataForGarbageCollection> - <armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel> - <armgcc.compiler.warnings.AllWarnings>True</armgcc.compiler.warnings.AllWarnings> - <armgcc.compiler.miscellaneous.OtherFlags>-std=c99</armgcc.compiler.miscellaneous.OtherFlags> - <armgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>True</armgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned> - <armgcccpp.compiler.symbols.DefSymbols> - <ListValues> - <Value>DEBUG</Value> - <Value>USB_VID=0x2341</Value> - <Value>USB_PID=0x004d</Value> - </ListValues> - </armgcccpp.compiler.symbols.DefSymbols> - <armgcccpp.compiler.directories.DefaultIncludePath>False</armgcccpp.compiler.directories.DefaultIncludePath> - <armgcccpp.compiler.directories.IncludePaths> - <ListValues> - <Value>../../../../../../../tools/CMSIS/Device/ATMEL</Value> - <Value>../../../../../../../tools/CMSIS/CMSIS/Include</Value> - <Value>../../..</Value> - <Value>../../../USB</Value> - <Value>../../../../../variants/arduino_zero</Value> - <Value>../../../../../libraries/SPI</Value> - <Value>../../../../../libraries/Wire</Value> - </ListValues> - </armgcccpp.compiler.directories.IncludePaths> - <armgcccpp.compiler.optimization.level>Optimize (-O1)</armgcccpp.compiler.optimization.level> - <armgcccpp.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcccpp.compiler.optimization.PrepareFunctionsForGarbageCollection> - <armgcccpp.compiler.optimization.PrepareDataForGarbageCollection>True</armgcccpp.compiler.optimization.PrepareDataForGarbageCollection> - <armgcccpp.compiler.optimization.DebugLevel>Maximum (-g3)</armgcccpp.compiler.optimization.DebugLevel> - <armgcccpp.compiler.warnings.AllWarnings>True</armgcccpp.compiler.warnings.AllWarnings> - <armgcccpp.compiler.miscellaneous.OtherFlags>-std=c++98</armgcccpp.compiler.miscellaneous.OtherFlags> - <armgcccpp.linker.general.UseNewlibNano>True</armgcccpp.linker.general.UseNewlibNano> - <armgcccpp.linker.libraries.Libraries> - <ListValues> - <Value>libm</Value> - </ListValues> - </armgcccpp.linker.libraries.Libraries> - <armgcccpp.linker.libraries.LibrarySearchPaths> - <ListValues> - <Value>../../../../../variants/arduino_zero/linker_scripts/gcc</Value> - </ListValues> - </armgcccpp.linker.libraries.LibrarySearchPaths> - <armgcccpp.linker.optimization.GarbageCollectUnusedSections>True</armgcccpp.linker.optimization.GarbageCollectUnusedSections> - <armgcccpp.linker.memorysettings.ExternalRAM /> - <armgcccpp.linker.miscellaneous.LinkerFlags>-Tflash.ld</armgcccpp.linker.miscellaneous.LinkerFlags> - <armgcccpp.assembler.general.IncludePaths> - <ListValues> - <Value>../../..</Value> - </ListValues> - </armgcccpp.assembler.general.IncludePaths> - <armgcccpp.assembler.debugging.DebugLevel>Default (-g)</armgcccpp.assembler.debugging.DebugLevel> - <armgcccpp.preprocessingassembler.general.DefaultIncludePath>False</armgcccpp.preprocessingassembler.general.DefaultIncludePath> - <armgcccpp.preprocessingassembler.general.IncludePaths> - <ListValues> - <Value>../../..</Value> - </ListValues> - </armgcccpp.preprocessingassembler.general.IncludePaths> - <armgcccpp.preprocessingassembler.debugging.DebugLevel>Default (-Wa,-g)</armgcccpp.preprocessingassembler.debugging.DebugLevel> - </ArmGccCpp> + <armgcc.common.outputfiles.hex>True</armgcc.common.outputfiles.hex> + <armgcc.common.outputfiles.lss>True</armgcc.common.outputfiles.lss> + <armgcc.common.outputfiles.eep>True</armgcc.common.outputfiles.eep> + <armgcc.common.outputfiles.bin>True</armgcc.common.outputfiles.bin> + <armgcc.common.outputfiles.srec>True</armgcc.common.outputfiles.srec> + <armgcc.compiler.general.ChangeDefaultCharTypeUnsigned>True</armgcc.compiler.general.ChangeDefaultCharTypeUnsigned> + <armgcc.compiler.symbols.DefSymbols> + <ListValues> + <Value>DEBUG</Value> + </ListValues> + </armgcc.compiler.symbols.DefSymbols> + <armgcc.compiler.directories.DefaultIncludePath>False</armgcc.compiler.directories.DefaultIncludePath> + <armgcc.compiler.directories.IncludePaths> + <ListValues> + <Value>../../../../../../../tools/CMSIS/Device/ATMEL</Value> + <Value>../../../../../../../tools/CMSIS/CMSIS/Include</Value> + <Value>../../..</Value> + <Value>../../../USB</Value> + <Value>../../../../../variants/arduino_zero</Value> + <Value>../../../../../libraries/SPI</Value> + <Value>../../../../../libraries/Wire</Value> + </ListValues> + </armgcc.compiler.directories.IncludePaths> + <armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcc.compiler.optimization.PrepareFunctionsForGarbageCollection> + <armgcc.compiler.optimization.PrepareDataForGarbageCollection>True</armgcc.compiler.optimization.PrepareDataForGarbageCollection> + <armgcc.compiler.optimization.DebugLevel>Maximum (-g3)</armgcc.compiler.optimization.DebugLevel> + <armgcc.compiler.warnings.AllWarnings>True</armgcc.compiler.warnings.AllWarnings> + <armgcc.compiler.miscellaneous.OtherFlags>-std=c99</armgcc.compiler.miscellaneous.OtherFlags> + <armgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned>True</armgcccpp.compiler.general.ChangeDefaultCharTypeUnsigned> + <armgcccpp.compiler.symbols.DefSymbols> + <ListValues> + <Value>DEBUG</Value> + <Value>USB_VID=0x2341</Value> + <Value>USB_PID=0x004d</Value> + </ListValues> + </armgcccpp.compiler.symbols.DefSymbols> + <armgcccpp.compiler.directories.DefaultIncludePath>False</armgcccpp.compiler.directories.DefaultIncludePath> + <armgcccpp.compiler.directories.IncludePaths> + <ListValues> + <Value>../../../../../../../tools/CMSIS/Device/ATMEL</Value> + <Value>../../../../../../../tools/CMSIS/CMSIS/Include</Value> + <Value>../../..</Value> + <Value>../../../USB</Value> + <Value>../../../../../variants/arduino_zero</Value> + <Value>../../../../../libraries/SPI</Value> + <Value>../../../../../libraries/Wire</Value> + </ListValues> + </armgcccpp.compiler.directories.IncludePaths> + <armgcccpp.compiler.optimization.level>Optimize (-O1)</armgcccpp.compiler.optimization.level> + <armgcccpp.compiler.optimization.PrepareFunctionsForGarbageCollection>True</armgcccpp.compiler.optimization.PrepareFunctionsForGarbageCollection> + <armgcccpp.compiler.optimization.PrepareDataForGarbageCollection>True</armgcccpp.compiler.optimization.PrepareDataForGarbageCollection> + <armgcccpp.compiler.optimization.DebugLevel>Maximum (-g3)</armgcccpp.compiler.optimization.DebugLevel> + <armgcccpp.compiler.warnings.AllWarnings>True</armgcccpp.compiler.warnings.AllWarnings> + <armgcccpp.compiler.miscellaneous.OtherFlags>-std=c++98</armgcccpp.compiler.miscellaneous.OtherFlags> + <armgcccpp.linker.libraries.Libraries> + <ListValues> + <Value>libm</Value> + </ListValues> + </armgcccpp.linker.libraries.Libraries> + <armgcccpp.linker.libraries.LibrarySearchPaths> + <ListValues> + <Value>../../../../../variants/arduino_zero/linker_scripts/gcc</Value> + </ListValues> + </armgcccpp.linker.libraries.LibrarySearchPaths> + <armgcccpp.linker.optimization.GarbageCollectUnusedSections>True</armgcccpp.linker.optimization.GarbageCollectUnusedSections> + <armgcccpp.linker.miscellaneous.LinkerFlags>-Tflash.ld</armgcccpp.linker.miscellaneous.LinkerFlags> + <armgcccpp.linker.memorysettings.ExternalRAM /> + <armgcccpp.assembler.general.IncludePaths> + <ListValues> + <Value>../../..</Value> + </ListValues> + </armgcccpp.assembler.general.IncludePaths> + <armgcccpp.assembler.debugging.DebugLevel>Default (-g)</armgcccpp.assembler.debugging.DebugLevel> + <armgcccpp.preprocessingassembler.general.DefaultIncludePath>False</armgcccpp.preprocessingassembler.general.DefaultIncludePath> + <armgcccpp.preprocessingassembler.general.IncludePaths> + <ListValues> + <Value>../../..</Value> + </ListValues> + </armgcccpp.preprocessingassembler.general.IncludePaths> + <armgcccpp.preprocessingassembler.debugging.DebugLevel>Default (-Wa,-g)</armgcccpp.preprocessingassembler.debugging.DebugLevel> +</ArmGccCpp> </ToolchainSettings> </PropertyGroup> <ItemGroup> @@ -391,6 +390,10 @@ <SubType>compile</SubType> <Link>core\wiring.h</Link> </Compile> + <Compile Include="..\..\wiring_analog.c"> + <SubType>compile</SubType> + <Link>core\wiring_analog.c</Link> + </Compile> <Compile Include="..\..\wiring_analog.h"> <SubType>compile</SubType> <Link>core\wiring_analog.h</Link> @@ -461,10 +464,6 @@ <SubType>compile</SubType> <Link>core\WInterrupts.c.disabled</Link> </None> - <None Include="..\..\wiring_analog.c.disabled"> - <SubType>compile</SubType> - <Link>core\wiring_analog.c.disabled</Link> - </None> <None Include="..\..\wiring_digital.c.old"> <SubType>compile</SubType> <Link>core\wiring_digital.c.old</Link> diff --git a/cores/arduino/validation/test.cpp b/cores/arduino/validation/test.cpp index 3c7e0b2e6a4eff37beef1ac11bd8ab7f08cd3b8c..25e92e6980a2c9dd441157ac0bd5104d77ef8e07 100644 --- a/cores/arduino/validation/test.cpp +++ b/cores/arduino/validation/test.cpp @@ -61,13 +61,38 @@ static void led_step2( void ) digitalWrite( PIN_LED3, LOW ) ; // set the red LED on } +static void analog_write_step (void) +{ + // test PWM generation on all PWM pins (duty cycle from 0x00 to 0xFF) + for( uint8_t duty_cycle = 0x00;duty_cycle<=0xFF;duty_cycle++) + { + analogWrite(13,duty_cycle); + analogWrite(12,duty_cycle); + analogWrite(11,duty_cycle); + analogWrite(10,duty_cycle); + analogWrite(9,duty_cycle); + analogWrite(8,duty_cycle); + analogWrite(7,duty_cycle); + analogWrite(6,duty_cycle); + analogWrite(5,duty_cycle); + analogWrite(4,duty_cycle); + analogWrite(3,duty_cycle); + analogWrite(2,duty_cycle); + delay( 10 ) ; + } + + +} + void loop( void ) { led_step1() ; delay( 1000 ) ; // wait for a second led_step2() ; delay( 1000 ) ; // wait for a second - + + analog_write_step(); + /* Serial1.write( '-' ) ; // send a char Serial1.write( "test1\n" ) ; // send a string diff --git a/cores/arduino/wiring_analog.c b/cores/arduino/wiring_analog.c index 0b1f4c9b14acb864d1902516373c81abf3f06714..7aa3c7f5dbaa782749b3682bbe94fab58dedd623 100644 --- a/cores/arduino/wiring_analog.c +++ b/cores/arduino/wiring_analog.c @@ -242,12 +242,29 @@ void analogWrite(uint32_t ulPin, uint32_t ulValue) { if ((attr & PIN_ATTR_PWM) == PIN_ATTR_PWM) { + if (g_APinDescription[ulPin].ulPinType == PIO_TIMER) + { // Set selected Pin as TC/TCC Waveform out (PMUX : E ) if(g_APinDescription[ulPin].ulPin <= 15) + { PORT->Group[g_APinDescription[ulPin].ulPort].WRCONFIG.reg = (uint32_t)(PORT_WRCONFIG_WRPINCFG |PORT_WRCONFIG_WRPMUX| 1 << (g_APinDescription[ulPin].ulPin)|(PORT_WRCONFIG_PMUXEN)|(0x4 << PORT_WRCONFIG_PMUX_Pos) ); - else + } else { PORT->Group[g_APinDescription[ulPin].ulPort].WRCONFIG.reg = (uint32_t)(PORT_WRCONFIG_WRPINCFG | PORT_WRCONFIG_WRPMUX| PORT_WRCONFIG_HWSEL| 1 << (g_APinDescription[ulPin].ulPin - 16)|(PORT_WRCONFIG_PMUXEN)|(0x4 << PORT_WRCONFIG_PMUX_Pos) ); - + } + } + + if (g_APinDescription[ulPin].ulPinType == PIO_TIMER_ALT) + { + // Set selected Pin as TC/TCC Waveform out (PMUX : F ) + if(g_APinDescription[ulPin].ulPin <= 15) + { + PORT->Group[g_APinDescription[ulPin].ulPort].WRCONFIG.reg = (uint32_t)(PORT_WRCONFIG_WRPINCFG |PORT_WRCONFIG_WRPMUX| 1 << (g_APinDescription[ulPin].ulPin)|(PORT_WRCONFIG_PMUXEN)|(0x5 << PORT_WRCONFIG_PMUX_Pos) ); + } else { + PORT->Group[g_APinDescription[ulPin].ulPort].WRCONFIG.reg = (uint32_t)(PORT_WRCONFIG_WRPINCFG | PORT_WRCONFIG_WRPMUX| PORT_WRCONFIG_HWSEL| 1 << (g_APinDescription[ulPin].ulPin - 16)|(PORT_WRCONFIG_PMUXEN)|(0x5 << PORT_WRCONFIG_PMUX_Pos) ); + } + } + + switch (g_APinDescription[ulPin].ulTCChannel) { case TC3_CH0 : diff --git a/variants/arduino_zero/variant.cpp b/variants/arduino_zero/variant.cpp index 76c9a3866c5cc8b4dfe1069967d4e30c21bc0804..4b572d6f5804c5bed966391d589574b773dd00cc 100644 --- a/variants/arduino_zero/variant.cpp +++ b/variants/arduino_zero/variant.cpp @@ -107,7 +107,7 @@ const PinDescription g_APinDescription[]= { PORTA, 19, PIO_TIMER, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM3_CH1, TC3_CH1 }, // TC3/WO[1] // 13 (LED) - { PORTA, 17, PIO_PWM, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM), No_ADC_Channel, PWM2_CH1, NOT_ON_TIMER }, // TCC2/WO[1] + { PORTA, 17, PIO_TIMER, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM2_CH1, TCC2_CH1 }, // TCC2/WO[1] // 14 (GND) { NOT_A_PORT, 0, PIO_NOT_A_PIN, PIN_ATTR_NONE, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER },