diff --git a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/settings/xmc4700.Debug.cspy.bat b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/settings/xmc4700.Debug.cspy.bat
index 6bb2ee10..253de130 100644
--- a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/settings/xmc4700.Debug.cspy.bat
+++ b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/settings/xmc4700.Debug.cspy.bat
@@ -25,7 +25,7 @@ if not "%~1" == "" goto debugFile
@echo on
-"C:\Program Files\IAR Systems\Embedded Workbench 9.0\common\bin\cspybat" -f "C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\settings\xmc4700.Debug.general.xcl" --backend -f "C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\settings\xmc4700.Debug.driver.xcl"
+"C:\Program Files\IAR Systems\Embedded Workbench 9.2\common\bin\cspybat" -f "C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\settings\xmc4700.Debug.general.xcl" --backend -f "C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\settings\xmc4700.Debug.driver.xcl"
@echo off
goto end
@@ -34,7 +34,7 @@ goto end
@echo on
-"C:\Program Files\IAR Systems\Embedded Workbench 9.0\common\bin\cspybat" -f "C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\settings\xmc4700.Debug.general.xcl" "--debug_file=%~1" --backend -f "C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\settings\xmc4700.Debug.driver.xcl"
+"C:\Program Files\IAR Systems\Embedded Workbench 9.2\common\bin\cspybat" -f "C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\settings\xmc4700.Debug.general.xcl" "--debug_file=%~1" --backend -f "C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\settings\xmc4700.Debug.driver.xcl"
@echo off
:end
\ No newline at end of file
diff --git a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/settings/xmc4700.Debug.driver.xcl b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/settings/xmc4700.Debug.driver.xcl
index 85ae8ee9..7569ab7b 100644
--- a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/settings/xmc4700.Debug.driver.xcl
+++ b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/settings/xmc4700.Debug.driver.xcl
@@ -6,7 +6,7 @@
"-p"
-"C:\Program Files\IAR Systems\Embedded Workbench 9.0\arm\CONFIG\debugger\Infineon\XMC4700-F144x2048.ddf"
+"C:\Program Files\IAR Systems\Embedded Workbench 9.2\arm\config\debugger\Infineon\XMC4700-F144x2048.ddf"
"--semihosting"
diff --git a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/settings/xmc4700.Debug.general.xcl b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/settings/xmc4700.Debug.general.xcl
index 42c2c687..b700884d 100644
--- a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/settings/xmc4700.Debug.general.xcl
+++ b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/settings/xmc4700.Debug.general.xcl
@@ -1,14 +1,14 @@
-"C:\Program Files\IAR Systems\Embedded Workbench 9.0\arm\bin\armPROC.dll"
+"C:\Program Files\IAR Systems\Embedded Workbench 9.2\arm\bin\armPROC.dll"
-"C:\Program Files\IAR Systems\Embedded Workbench 9.0\arm\bin\armJLINK.dll"
+"C:\Program Files\IAR Systems\Embedded Workbench 9.2\arm\bin\armJLINK.dll"
"C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\..\bin\openblt_xmc4700.out"
---plugin="C:\Program Files\IAR Systems\Embedded Workbench 9.0\arm\bin\armbat.dll"
+--plugin="C:\Program Files\IAR Systems\Embedded Workbench 9.2\arm\bin\armbat.dll"
---device_macro="C:\Program Files\IAR Systems\Embedded Workbench 9.0\arm\config\debugger\Infineon\XMC4700.dmac"
+--device_macro="C:\Program Files\IAR Systems\Embedded Workbench 9.2\arm/config/debugger/Infineon/XMC4700.dmac"
---flash_loader="C:\Program Files\IAR Systems\Embedded Workbench 9.0\arm\config\flashloader\Infineon\FlashXMC4700_2048K.board"
+--flash_loader="C:\Program Files\IAR Systems\Embedded Workbench 9.2\arm/config/flashloader/Infineon/FlashXMC4700_2048K.board"
diff --git a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/settings/xmc4700.wsdt b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/settings/xmc4700.wsdt
index b8e09a5e..b618b7c6 100644
--- a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/settings/xmc4700.wsdt
+++ b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/settings/xmc4700.wsdt
@@ -186,7 +186,7 @@
1918512
-
+ 0-1
@@ -243,9 +243,6 @@
xmc4700xmc4700/Boot
- xmc4700/Boot/lib
- xmc4700/Boot/lib/cmsis
- xmc4700/Boot/lib/xmclibxmc4700/Outputxmc4700/Sourcexmc4700/Source/ARMCM4_XMC4
@@ -253,7 +250,7 @@
14
- 32
+ 361
@@ -267,12 +264,12 @@
09000D8400000F84000008840000FFFFFFFF54840000328100001C8100000984000053840000
- 0600048400004D000000068400004F00000030840000530000000E840000510000000B810000220000000D81000024000000
+ 0600048400004D000000068400004F0000000E8400005100000030840000530000000B8100001E0000000D8100002000000000A0000000A0000006E0000006E000000
- 00000000F00300008007000003040000
+ 00000000F20300008007000003040000409600
@@ -299,7 +296,7 @@
429496729500000000EB0200008007000025040000
- 00000000B602000080070000F0030000
+ 00000000B802000080070000F2030000409600
@@ -312,7 +309,7 @@
34052000000003500000022010000E6000000
- 04000000CE0200007C070000D6030000
+ 04000000D00200007C070000D80300003276800
@@ -335,20 +332,20 @@
_I0
- 607
+ 60640
- 1222
+ 1223202
- C:\Work\software\OpenBLT\Target\Demo\ARMCM4_XMC4_XMC4700_Relax_Kit_IAR\Boot\ide\BuildLog.log
+ $WS_DIR$\BuildLog.log0-134048000000003500000022010000E6000000
- 04000000CE0200007C070000D6030000
+ 04000000D00200007C070000D8030000409600
@@ -361,7 +358,7 @@
34056000000003500000022010000E6000000
- 04000000CE0200007C070000D6030000
+ 04000000D00200007C070000D8030000409600
@@ -376,14 +373,14 @@
9511422
-
+ 0-134057000000003500000022010000E6000000
- 04000000CE0200007C070000D6030000
+ 04000000D00200007C070000D8030000409600
@@ -398,14 +395,14 @@
9511422
-
+ 0-134058000000003500000022010000E6000000
- 04000000CE0200007C070000D6030000
+ 04000000D00200007C070000D8030000409600
@@ -419,7 +416,7 @@
34059000000003500000022010000E6000000
- 04000000CE0200007C070000D6030000
+ 04000000D00200007C070000D8030000409600
@@ -434,14 +431,14 @@
9511422
-
+ 0-134062000000003500000022010000E6000000
- 04000000CE0200007C070000D6030000
+ 04000000D00200007C070000D8030000409600
@@ -453,7 +450,7 @@
2
-
+ 0-1
@@ -475,16 +472,16 @@
2
-
+
-
+ <Right-click on a symbol in the editor to show a call graph>
-
+ 0
@@ -493,7 +490,7 @@
0
-
+ 0
@@ -613,7 +610,7 @@
3406300000000350000000601000096010000
- 000000003200000006010000B2020000
+ 000000003200000006010000B4020000409600
@@ -624,11 +621,11 @@
1
- 0000000010000000000000000010000001000000FFFFFFFFFFFFFFFF06010000320000000A010000B20200000100000002000010040000000100000000000000000000000F85000000000000000000000000000000000000010000000F850000010000000F850000000000000080000000000000FFFFFFFFFFFFFFFF000000000000000004000000040000000000000001000000040000000100000000000000000000000D85000000000000000000000000000000000000010000000D850000010000000D850000000000000080000000000000FFFFFFFFFFFFFFFF000000000000000004000000040000000000000001000000040000000100000000000000000000000C85000000000000000000000000000000000000010000000C850000010000000C850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000078500000000000000000000000000000000000001000000078500000100000007850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000068500000000000000000000000000000000000001000000068500000100000006850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000058500000000000000000000000000000000000001000000058500000100000005850000000000000080000001000000FFFFFFFFFFFFFFFF00000000B202000080070000B602000001000000010000100400000001000000FCFCFFFF6F000000FFFFFFFF07000000048500000085000008850000098500000A8500000B8500000E850000FFFF02000B004354616262656450616E65008000000100000000000000EB020000800700002504000000000000B602000080070000F0030000000000004080005607000000FFFEFF054200750069006C006400010000000485000001000000FFFFFFFFFFFFFFFFFFFEFF094400650062007500670020004C006F006700010000000085000001000000FFFFFFFFFFFFFFFFFFFEFF0C4400650063006C00610072006100740069006F006E007300000000000885000001000000FFFFFFFFFFFFFFFFFFFEFF0A5200650066006500720065006E00630065007300000000000985000001000000FFFFFFFFFFFFFFFFFFFEFF0D460069006E006400200069006E002000460069006C0065007300000000000A85000001000000FFFFFFFFFFFFFFFFFFFEFF1541006D0062006900670075006F0075007300200044006500660069006E006900740069006F006E007300000000000B85000001000000FFFFFFFFFFFFFFFFFFFEFF0B54006F006F006C0020004F0075007400700075007400000000000E85000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFF0485000001000000FFFFFFFF04850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000038500000000000000000000000000000000000001000000038500000100000003850000000000000000000000000000
+ 0000000010000000000000000010000001000000FFFFFFFFFFFFFFFF06010000320000000A010000B40200000100000002000010040000000100000000000000000000000F85000000000000000000000000000000000000010000000F850000010000000F850000000000000080000000000000FFFFFFFFFFFFFFFF000000000000000004000000040000000000000001000000040000000100000000000000000000000D85000000000000000000000000000000000000010000000D850000010000000D850000000000000080000000000000FFFFFFFFFFFFFFFF000000000000000004000000040000000000000001000000040000000100000000000000000000000C85000000000000000000000000000000000000010000000C850000010000000C850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000078500000000000000000000000000000000000001000000078500000100000007850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000068500000000000000000000000000000000000001000000068500000100000006850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000058500000000000000000000000000000000000001000000058500000100000005850000000000000080000001000000FFFFFFFFFFFFFFFF00000000B402000080070000B802000001000000010000100400000001000000FCFCFFFF6F000000FFFFFFFF07000000048500000085000008850000098500000A8500000B8500000E850000FFFF02000B004354616262656450616E65008000000100000000000000EB020000800700002504000000000000B802000080070000F2030000000000004080005607000000FFFEFF054200750069006C006400010000000485000001000000FFFFFFFFFFFFFFFFFFFEFF094400650062007500670020004C006F006700010000000085000001000000FFFFFFFFFFFFFFFFFFFEFF0C4400650063006C00610072006100740069006F006E007300000000000885000001000000FFFFFFFFFFFFFFFFFFFEFF0A5200650066006500720065006E00630065007300000000000985000001000000FFFFFFFFFFFFFFFFFFFEFF0D460069006E006400200069006E002000460069006C0065007300000000000A85000001000000FFFFFFFFFFFFFFFFFFFEFF1541006D0062006900670075006F0075007300200044006500660069006E006900740069006F006E007300000000000B85000001000000FFFFFFFFFFFFFFFFFFFEFF0B54006F006F006C0020004F0075007400700075007400000000000E85000001000000FFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000001000000FFFFFFFF0485000001000000FFFFFFFF04850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000038500000000000000000000000000000000000001000000038500000100000003850000000000000000000000000000CMSIS-Pack
- 00200000010000000100FFFF01001100434D4643546F6F6C426172427574746F6ED1840000020000000A000000FFFEFF00000000000000000000000000010000000100000000000000FFFEFF0A43004D005300490053002D005000610063006B0018000000
+ 00200000010000000100FFFF01001100434D4643546F6F6C426172427574746F6ED18400000200000008000000FFFEFF00000000000000000000000000010000000100000000000000FFFEFF0A43004D005300490053002D005000610063006B001800000034049
@@ -699,7 +696,7 @@
Main
- 00200000010000002000FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000036000000FFFEFF000000000000000000000000000100000001000000018001E100000000000037000000FFFEFF000000000000000000000000000100000001000000018003E100000000000039000000FFFEFF000000000000000000000000000100000001000000018000810000000000001D000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000018007E10000000000003C000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000018023E10000000004003E000000FFFEFF000000000000000000000000000100000001000000018022E10000000004003D000000FFFEFF000000000000000000000000000100000001000000018025E100000000040040000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001802BE100000000040043000000FFFEFF00000000000000000000000000010000000100000001802CE100000000040044000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000FFFF01000D005061737465436F6D626F426F784281000000000000FFFFFFFFFFFEFF0001000000000000000100000000000000010000007800000002002050FFFFFFFFFFFEFF0096000000000000000000018021810000000004002F000000FFFEFF000000000000000000000000000100000001000000018024E10000000000003F000000FFFEFF000000000000000000000000000100000001000000018028E100000000040041000000FFFEFF000000000000000000000000000100000001000000018029E100000000000042000000FFFEFF000000000000000000000000000100000001000000018002810000000000001E000000FFFEFF0000000000000000000000000001000000010000000180298100000000000033000000FFFEFF0000000000000000000000000001000000010000000180278100000000000031000000FFFEFF0000000000000000000000000001000000010000000180288100000000000032000000FFFEFF00000000000000000000000000010000000100000001801D810000000000002B000000FFFEFF00000000000000000000000000010000000100000001801E810000000004002C000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001800B8100000200000022000000FFFEFF00000000000000000000000000010000000100000001800C8100000200000023000000FFFEFF00000000000000000000000000010000000100000001805F8600000000000035000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001800E8100000200000025000000FFFEFF00000000000000000000000000010000000100000001800F8100000200000026000000FFFEFF00000000000000000000000000010000000100000000000000FFFEFF044D00610069006E00E8020000
+ 00200000010000002000FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000039000000FFFEFF000000000000000000000000000100000001000000018001E10000000000003A000000FFFEFF000000000000000000000000000100000001000000018003E10000000004003C000000FFFEFF0000000000000000000000000001000000010000000180008100000000000019000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000018007E10000000004003F000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000018023E100000000000041000000FFFEFF000000000000000000000000000100000001000000018022E100000000040040000000FFFEFF000000000000000000000000000100000001000000018025E100000000000042000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001802BE100000000040043000000FFFEFF00000000000000000000000000010000000100000001802CE100000000040044000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000FFFF01000D005061737465436F6D626F426F784281000000000400FFFFFFFFFFFEFF0000000000000000000100000000000000010000007800000002002050FFFFFFFFFFFEFF0096000000000000000000018021810000000004002B000000FFFEFF000000000000000000000000000100000001000000018024E100000000040034000000FFFEFF000000000000000000000000000100000001000000018028E100000000040033000000FFFEFF000000000000000000000000000100000001000000018029E100000000040035000000FFFEFF000000000000000000000000000100000001000000018002810000000004001A000000FFFEFF000000000000000000000000000100000001000000018029810000000004002F000000FFFEFF000000000000000000000000000100000001000000018027810000000004002D000000FFFEFF000000000000000000000000000100000001000000018028810000000004002E000000FFFEFF00000000000000000000000000010000000100000001801D8100000000040027000000FFFEFF00000000000000000000000000010000000100000001801E8100000000040028000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001800B810000020004001E000000FFFEFF00000000000000000000000000010000000100000001800C810000020000001F000000FFFEFF00000000000000000000000000010000000100000001805F8600000200040032000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001800E8100000200000021000000FFFEFF00000000000000000000000000010000000100000001800F8100000200000022000000FFFEFF00000000000000000000000000010000000100000000000000FFFEFF044D00610069006E00E802000034064
@@ -751,7 +748,7 @@
- 010000000300000001000000000000000000000001000000010000000200000000000000010000000100000000000000280000002800000001000000020000000000000001000000FFFEFF122400570053005F0044004900520024005C002E002E005C006D00610069006E002E00630001000000FFFF010014004966436F6E74656E7453746F72616765496D706CFFFEFF00FFFEFFFF27013C003F0078006D006C002000760065007200730069006F006E003D00220031002E0030002200200065006E0063006F00640069006E0067003D0022005500540046002D00380022003F003E000A003C0052006F006F0074003E000A0020002000200020003C004E0075006D0052006F00770073003E0031003C002F004E0075006D0052006F00770073003E000A0020002000200020003C004E0075006D0043006F006C0073003E0031003C002F004E0075006D0043006F006C0073003E000A0020002000200020003C00580050006F0073003E0030003C002F00580050006F0073003E000A0020002000200020003C00590050006F0073003E0030003C002F00590050006F0073003E000A0020002000200020003C00530065006C00530074006100720074003E0030003C002F00530065006C00530074006100720074003E000A0020002000200020003C00530065006C0045006E0064003E0030003C002F00530065006C0045006E0064003E000A0020002000200020003C00580050006F00730032003E0030003C002F00580050006F00730032003E000A0020002000200020003C00590050006F00730032003E00330034003C002F00590050006F00730032003E000A0020002000200020003C00530065006C005300740061007200740032003E0032003600330031003C002F00530065006C005300740061007200740032003E000A0020002000200020003C00530065006C0045006E00640032003E0032003600330031003C002F00530065006C0045006E00640032003E000A003C002F0052006F006F0074003E000A00FFFEFF066D00610069006E002E00630000000000FFFFFFFFFFFFFFFFFFFEFF2F2400570053005F0044004900520024005C002E002E005C006C00690062005C00460061007400460053005C00530044004D004D0043005F0042004C004F0043004B005C00730064006D006D0063005F0062006C006F0063006B002E006800010000000180FFFEFF00FFFEFFFF27013C003F0078006D006C002000760065007200730069006F006E003D00220031002E0030002200200065006E0063006F00640069006E0067003D0022005500540046002D00380022003F003E000A003C0052006F006F0074003E000A0020002000200020003C004E0075006D0052006F00770073003E0031003C002F004E0075006D0052006F00770073003E000A0020002000200020003C004E0075006D0043006F006C0073003E0031003C002F004E0075006D0043006F006C0073003E000A0020002000200020003C00580050006F0073003E0030003C002F00580050006F0073003E000A0020002000200020003C00590050006F0073003E0030003C002F00590050006F0073003E000A0020002000200020003C00530065006C00530074006100720074003E0030003C002F00530065006C00530074006100720074003E000A0020002000200020003C00530065006C0045006E0064003E0030003C002F00530065006C0045006E0064003E000A0020002000200020003C00580050006F00730032003E0030003C002F00580050006F00730032003E000A0020002000200020003C00590050006F00730032003E00360031003C002F00590050006F00730032003E000A0020002000200020003C00530065006C005300740061007200740032003E0033003200340039003C002F00530065006C005300740061007200740032003E000A0020002000200020003C00530065006C0045006E00640032003E0033003200340039003C002F00530065006C0045006E00640032003E000A003C002F0052006F006F0074003E000A00FFFEFF0D730064006D006D0063005F0062006C006F0063006B002E00680000000000FFFFFFFFFFFFFFFF0000000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD5000100000001000000020000000A0100006700000080070000E7020000
+ 010000000300000001000000000000000000000001000000010000000200000000000000010000000100000000000000280000002800000000000000
diff --git a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/xmc4700.ewd b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/xmc4700.ewd
index c3622a6d..70c4ae5f 100644
--- a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/xmc4700.ewd
+++ b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/xmc4700.ewd
@@ -1,6 +1,6 @@
- 3
+ 4Debug
@@ -11,7 +11,7 @@
C-SPY2
- 32
+ 3311
+
+
+
+
+
+
+
+
@@ -457,6 +489,39 @@
+
+ E2_ID
+ 2
+
+ 0
+ 1
+ 1
+
+
+
+
+
+
+
+ GDBSERVER_ID2
@@ -1072,7 +1137,7 @@
STLINK_ID2
- 7
+ 811
+
+
@@ -1292,7 +1365,7 @@
XDS100_ID2
- 8
+ 911
+
@@ -1502,17 +1579,25 @@
0
- $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm9.ewplugin
- 0
-
-
- $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm9BE.ewplugin
+ $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm9a.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0
+
+ $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin
+ 0
+
+
+ $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin
+ 0
+
+
+ $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin
+ 0
+ $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0
@@ -1537,7 +1622,7 @@
C-SPY2
- 32
+ 3310
+
+
+
+
+
+
+
+
@@ -1983,6 +2100,39 @@
+
+ E2_ID
+ 2
+
+ 0
+ 1
+ 0
+
+
+
+
+
+
+
+ GDBSERVER_ID2
@@ -2598,7 +2748,7 @@
STLINK_ID2
- 7
+ 810
+
+
@@ -2818,7 +2976,7 @@
XDS100_ID2
- 8
+ 910
+
@@ -3028,17 +3190,25 @@
0
- $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm9.ewplugin
- 0
-
-
- $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm9BE.ewplugin
+ $TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm9a.ewplugin0$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin0
+
+ $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin
+ 0
+
+
+ $TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-KA-CSpy.ewplugin
+ 0
+
+
+ $TOOLKIT_DIR$\plugins\rtos\uCOS-III\uCOS-III-KA-CSpy.ewplugin
+ 0
+ $EW_DIR$\common\plugins\Orti\Orti.ENU.ewplugin0
diff --git a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/xmc4700.ewp b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/xmc4700.ewp
index a8bf57e5..40bb1548 100644
--- a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/xmc4700.ewp
+++ b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/xmc4700.ewp
@@ -1,6 +1,6 @@
- 3
+ 4Debug
@@ -11,7 +11,7 @@
General3
- 33
+ 3611
+
+
+
+
ICCARM2
- 37
+ 3811
+
+
AARM2
- 11
+ 1211
+
@@ -670,19 +699,11 @@
inputOutputBased
-
- BUILDACTION
- 1
-
-
-
-
- ILINK0
- 25
+ 2711
+
+
+
+
@@ -1057,6 +1094,11 @@
+
+ BUILDACTION
+ 2
+
+ Release
@@ -1068,7 +1110,7 @@
General3
- 33
+ 3610
+
+
+
+
ICCARM2
- 37
+ 3810
+
+
AARM2
- 11
+ 1210
+
@@ -1712,19 +1783,11 @@
inputOutputBased
-
- BUILDACTION
- 1
-
-
-
-
- ILINK0
- 25
+ 2710
+
+
+
+
@@ -2099,6 +2178,11 @@
+
+ BUILDACTION
+ 2
+
+ Boot
@@ -2566,6 +2650,9 @@
$PROJ_DIR$\..\..\..\..\Source\ARMCM4_XMC4\flash.h
+
+ $PROJ_DIR$\..\..\..\..\Source\ARMCM4_XMC4\mbrtu.c
+ $PROJ_DIR$\..\..\..\..\Source\ARMCM4_XMC4\nvm.c
@@ -2699,6 +2786,12 @@
$PROJ_DIR$\..\..\..\..\Source\file.h
+
+ $PROJ_DIR$\..\..\..\..\Source\mb.c
+
+
+ $PROJ_DIR$\..\..\..\..\Source\mb.h
+ $PROJ_DIR$\..\..\..\..\Source\net.c
diff --git a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/xmc4700.ewt b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/xmc4700.ewt
index 4b43e43d..70229b60 100644
--- a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/xmc4700.ewt
+++ b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_IAR/Boot/ide/xmc4700.ewt
@@ -1,6 +1,6 @@
- 3
+ 4Debug
@@ -9,9 +9,9 @@
1C-STAT
- 515
+ 517
- 515
+ 5170
@@ -25,7 +25,7 @@
Debug\C-STAT
- 2.3.1
+ 2.5.2
@@ -356,6 +356,7 @@
+
@@ -798,6 +799,7 @@
+
@@ -830,6 +832,7 @@
+
@@ -840,7 +843,8 @@
-
+
+
@@ -946,6 +950,7 @@
+
@@ -1063,6 +1068,7 @@
+
@@ -1428,9 +1434,9 @@
0C-STAT
- 515
+ 517
- 515
+ 5170
@@ -1444,7 +1450,7 @@
Release\C-STAT
- 2.3.1
+ 2.5.2
@@ -1775,6 +1781,7 @@
+
@@ -2217,6 +2224,7 @@
+
@@ -2249,6 +2257,7 @@
+
@@ -2259,7 +2268,8 @@
-
+
+
@@ -2365,6 +2375,7 @@
+
@@ -2482,6 +2493,7 @@
+
@@ -3305,6 +3317,9 @@
$PROJ_DIR$\..\..\..\..\Source\ARMCM4_XMC4\flash.h
+
+ $PROJ_DIR$\..\..\..\..\Source\ARMCM4_XMC4\mbrtu.c
+ $PROJ_DIR$\..\..\..\..\Source\ARMCM4_XMC4\nvm.c
@@ -3438,6 +3453,12 @@
$PROJ_DIR$\..\..\..\..\Source\file.h
+
+ $PROJ_DIR$\..\..\..\..\Source\mb.c
+
+
+ $PROJ_DIR$\..\..\..\..\Source\mb.h
+ $PROJ_DIR$\..\..\..\..\Source\net.c
diff --git a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_Keil/Boot/ide/xmc4700.uvoptx b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_Keil/Boot/ide/xmc4700.uvoptx
index 1229f1e4..7decf5ef 100644
--- a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_Keil/Boot/ide/xmc4700.uvoptx
+++ b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_Keil/Boot/ide/xmc4700.uvoptx
@@ -1547,7 +1547,7 @@
Lib/TinyUSB
- 1
+ 0000
@@ -2239,6 +2239,30 @@
00
+
+ 8
+ 165
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\..\Source\mb.c
+ mb.c
+ 0
+ 0
+
+
+ 8
+ 166
+ 5
+ 0
+ 0
+ 0
+ ..\..\..\..\Source\mb.h
+ mb.h
+ 0
+ 0
+
@@ -2249,7 +2273,7 @@
09
- 165
+ 167100
@@ -2261,7 +2285,7 @@
9
- 166
+ 168100
@@ -2273,7 +2297,7 @@
9
- 167
+ 169100
@@ -2285,7 +2309,7 @@
9
- 168
+ 170500
@@ -2297,7 +2321,7 @@
9
- 169
+ 171100
@@ -2309,7 +2333,7 @@
9
- 170
+ 172100
@@ -2321,7 +2345,7 @@
9
- 171
+ 173100
@@ -2333,7 +2357,7 @@
9
- 172
+ 174500
@@ -2345,7 +2369,7 @@
9
- 173
+ 175100
@@ -2357,7 +2381,7 @@
9
- 174
+ 176100
@@ -2367,6 +2391,18 @@
00
+
+ 9
+ 177
+ 1
+ 0
+ 0
+ 0
+ ..\..\..\..\Source\ARMCM4_XMC4\mbrtu.c
+ mbrtu.c
+ 0
+ 0
+
@@ -2377,7 +2413,7 @@
010
- 175
+ 178500
@@ -2389,7 +2425,7 @@
10
- 176
+ 179100
@@ -2401,7 +2437,7 @@
10
- 177
+ 180500
@@ -2413,7 +2449,7 @@
10
- 178
+ 181500
@@ -2425,7 +2461,7 @@
10
- 179
+ 182100
@@ -2445,7 +2481,7 @@
011
- 180
+ 183500
@@ -2457,7 +2493,7 @@
11
- 181
+ 184500
@@ -2469,7 +2505,7 @@
11
- 182
+ 185500
@@ -2481,7 +2517,7 @@
11
- 183
+ 186500
@@ -2493,7 +2529,7 @@
11
- 184
+ 187500
@@ -2505,7 +2541,7 @@
11
- 185
+ 188100
@@ -2517,7 +2553,7 @@
11
- 186
+ 189500
@@ -2529,7 +2565,7 @@
11
- 187
+ 190500
@@ -2541,7 +2577,7 @@
11
- 188
+ 191100
@@ -2553,7 +2589,7 @@
11
- 189
+ 192500
@@ -2565,7 +2601,7 @@
11
- 190
+ 193100
@@ -2577,7 +2613,7 @@
11
- 191
+ 194500
@@ -2589,7 +2625,7 @@
11
- 192
+ 195100
@@ -2601,7 +2637,7 @@
11
- 193
+ 196500
@@ -2613,7 +2649,7 @@
11
- 194
+ 197500
@@ -2625,7 +2661,7 @@
11
- 195
+ 198100
@@ -2637,7 +2673,7 @@
11
- 196
+ 199500
diff --git a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_Keil/Boot/ide/xmc4700.uvprojx b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_Keil/Boot/ide/xmc4700.uvprojx
index bdf14338..7201e36f 100644
--- a/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_Keil/Boot/ide/xmc4700.uvprojx
+++ b/Target/Demo/ARMCM4_XMC4_XMC4700_Relax_Kit_Keil/Boot/ide/xmc4700.uvprojx
@@ -1289,6 +1289,16 @@
5..\..\..\..\Source\xcp.h
+
+ mb.c
+ 1
+ ..\..\..\..\Source\mb.c
+
+
+ mb.h
+ 5
+ ..\..\..\..\Source\mb.h
+
@@ -1395,6 +1405,11 @@
+
+ mbrtu.c
+ 1
+ ..\..\..\..\Source\ARMCM4_XMC4\mbrtu.c
+
diff --git a/Target/Source/ARMCM4_XMC4/mbrtu.c b/Target/Source/ARMCM4_XMC4/mbrtu.c
new file mode 100644
index 00000000..63db9ce8
--- /dev/null
+++ b/Target/Source/ARMCM4_XMC4/mbrtu.c
@@ -0,0 +1,542 @@
+/************************************************************************************//**
+* \file Source/ARMCM4_XMC4/mbrtu.c
+* \brief Bootloader Modbus RTU communication interface source file.
+* \ingroup Target_ARMCM4_XMC4
+* \internal
+*----------------------------------------------------------------------------------------
+* C O P Y R I G H T
+*----------------------------------------------------------------------------------------
+* Copyright (c) 2023 by Feaser http://www.feaser.com All rights reserved
+*
+*----------------------------------------------------------------------------------------
+* L I C E N S E
+*----------------------------------------------------------------------------------------
+* This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
+* modify it under the terms of the GNU General Public License as published by the Free
+* Software Foundation, either version 3 of the License, or (at your option) any later
+* version.
+*
+* OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+* PURPOSE. See the GNU General Public License for more details.
+*
+* You have received a copy of the GNU General Public License along with OpenBLT. It
+* should be located in ".\Doc\license.html". If not, contact Feaser to obtain a copy.
+*
+* \endinternal
+****************************************************************************************/
+
+/****************************************************************************************
+* Include files
+****************************************************************************************/
+#include "boot.h" /* bootloader generic header */
+#if (BOOT_COM_MBRTU_ENABLE > 0)
+#include "xmc_uart.h" /* UART driver header */
+
+
+/****************************************************************************************
+* Macro definitions
+****************************************************************************************/
+/** \brief Timeout for transmitting a byte in milliseconds. */
+#define MBRTU_BYTE_TX_TIMEOUT_MS (10u)
+
+/** \brief Macro for accessing the UART channel handle in the format that is expected
+ * by the XMClib UART driver.
+ */
+#define MBRTU_CHANNEL ((XMC_USIC_CH_t *)(mbrtuChannelMap[BOOT_COM_MBRTU_CHANNEL_INDEX]))
+
+
+/****************************************************************************************
+* Local constant declarations
+****************************************************************************************/
+/** \brief Helper array to quickly convert the channel index, as specific in the boot-
+ * loader's configuration header, to the associated channel handle that the
+ * XMClib's UART driver requires.
+ */
+static const XMC_USIC_CH_t *mbrtuChannelMap[] =
+{
+ XMC_UART0_CH0, /* BOOT_COM_MBRTU_CHANNEL_INDEX = 0 */
+ XMC_UART0_CH1, /* BOOT_COM_MBRTU_CHANNEL_INDEX = 1 */
+ XMC_UART1_CH0, /* BOOT_COM_MBRTU_CHANNEL_INDEX = 2 */
+ XMC_UART1_CH1, /* BOOT_COM_MBRTU_CHANNEL_INDEX = 3 */
+ XMC_UART2_CH0, /* BOOT_COM_MBRTU_CHANNEL_INDEX = 4 */
+ XMC_UART2_CH1 /* BOOT_COM_MBRTU_CHANNEL_INDEX = 5 */
+};
+
+
+/****************************************************************************************
+* Local data declarations
+****************************************************************************************/
+/** \brief Stores the number of free running counter ticks that represents the 3.5
+ * character delay time (T3_5) for Modbus RTU.
+ */
+static blt_int16u mbRtuT3_5Ticks;
+
+
+/****************************************************************************************
+* Function prototypes
+****************************************************************************************/
+static blt_bool MbRtuReceiveByte(blt_int8u *data);
+static void MbRtuTransmitByte(blt_int8u data, blt_bool end_of_packet);
+
+
+/************************************************************************************//**
+** \brief Initializes the Modbus RTU communication interface.
+** \attention It is the application's responsibility to initialize a timer peripheral
+** to have an upwards counting free running counter, which runs at 100 kHz.
+** \return none.
+**
+****************************************************************************************/
+void MbRtuInit(void)
+{
+ blt_int16u startTimeTicks;
+ blt_int16u deltaTimeTicks;
+ blt_int16u currentTimeTicks;
+ blt_int8u rxDummy;
+ XMC_UART_CH_CONFIG_t uart_config;
+
+ /* the current implementation supports XMC_UART0_CH0 to XMC_UART2_CH1. throw an
+ * assertion error in case a different UART channel is configured.
+ */
+ ASSERT_CT((BOOT_COM_MBRTU_CHANNEL_INDEX >= 0) && (BOOT_COM_MBRTU_CHANNEL_INDEX <= 5));
+
+ /* calculate the 3.5 character delay time in free running counter ticks. note that
+ * the free running counter runs at 100 kHz, so one tick is 10 us. For baudrates >
+ * 19200 bps, it can be fixed to 1750 us.
+ */
+ if (BOOT_COM_MBRTU_BAUDRATE > 19200)
+ {
+ /* set T3_5 time to a fixed value of 1750 us. */
+ mbRtuT3_5Ticks = 175;
+ }
+ /* calculate the T3_5 time, because the baudrate is <= 19200 bps. */
+ else
+ {
+ /* T3_5 [us * 10] = 3.5 * Tchar = 3.5 * 11 * 100000 / baudrate = 3850000 / baudrate.
+ * make sure to do integer round up though. Make sure to add 1 to adjust for 10us
+ * timer resolution inaccuracy.
+ */
+ mbRtuT3_5Ticks = (blt_int16u)(((3850000UL + (BOOT_COM_MBRTU_BAUDRATE - 1U)) /
+ BOOT_COM_MBRTU_BAUDRATE) + 1);
+ }
+
+ /* set configuration and initialize UART channel */
+ uart_config.baudrate = BOOT_COM_MBRTU_BAUDRATE;
+ uart_config.data_bits = 8;
+ uart_config.frame_length = 8;
+ uart_config.stop_bits = BOOT_COM_MBRTU_STOPBITS;
+ uart_config.oversampling = 16;
+ uart_config.parity_mode = XMC_USIC_CH_PARITY_MODE_NONE;
+ /* odd parity enabled? */
+ #if (BOOT_COM_MBRTU_PARITY == 1)
+ uart_config.parity_mode = XMC_USIC_CH_PARITY_MODE_ODD;
+ #endif
+ /* even parity enabled? */
+ #if (BOOT_COM_MBRTU_PARITY == 2)
+ uart_config.parity_mode = XMC_USIC_CH_PARITY_MODE_EVEN;
+ #endif
+ XMC_UART_CH_Init(MBRTU_CHANNEL, &uart_config);
+ /* configure small transmit and receive FIFO */
+ XMC_USIC_CH_TXFIFO_Configure(MBRTU_CHANNEL, 16U, XMC_USIC_CH_FIFO_SIZE_16WORDS, 1U);
+ XMC_USIC_CH_RXFIFO_Configure(MBRTU_CHANNEL, 0U, XMC_USIC_CH_FIFO_SIZE_16WORDS, 1U);
+ /* configure RCIM bits to make sure it detects the parity error (PERR) as RCI[4]. */
+ MBRTU_CHANNEL->RBCTR |= USIC_CH_RBCTR_RCIM_Msk;
+ /* start UART */
+ XMC_UART_CH_Start(MBRTU_CHANNEL);
+
+ /* enable the receiver output to be able to receive. */
+ MbRtuDriverOutputControlHook(BLT_FALSE);
+
+ /* wait for idle line detection. This is T3_5 time after reception of the last byte. */
+ startTimeTicks = MbRtuFreeRunningCounterGet();
+ do
+ {
+ /* service the watchdog. */
+ CopService();
+ /* get the current value of the free running counter. */
+ currentTimeTicks = MbRtuFreeRunningCounterGet();
+ /* check if a byte was received while waiting for the idle line. */
+ if (MbRtuReceiveByte(&rxDummy) == BLT_TRUE)
+ {
+ /* restart the idle line detection. */
+ startTimeTicks = currentTimeTicks;
+ }
+ /* calculate the number of ticks that elapsed since the start or since the last
+ * byte reception. Note that this calculation works, even if the free running counter
+ * overflowed.
+ */
+ deltaTimeTicks = currentTimeTicks - startTimeTicks;
+ }
+ while (deltaTimeTicks < mbRtuT3_5Ticks);
+} /*** end of MbRtuInit ***/
+
+
+/************************************************************************************//**
+** \brief Transmits a packet formatted for the communication interface.
+** \param data Pointer to byte array with data that it to be transmitted.
+** \param len Number of bytes that are to be transmitted.
+** \return none.
+**
+****************************************************************************************/
+void MbRtuTransmitPacket(blt_int8u *data, blt_int8u len)
+{
+ blt_int16u data_index;
+ blt_int16u checksum;
+ blt_bool endOfPacket = BLT_FALSE;
+ /* Made static to lower stack load and +5 for Modbus RTU packet overhead. */
+ static blt_int8u txPacket[BOOT_COM_MBRTU_TX_MAX_DATA + 5];
+
+ /* On Modbus RTU, there must always be a T3_5 time separation between packet trans-
+ * missions.
+ *
+ * This bootloader uses XCP packets embedded in Modbus RTU packets. The XCP
+ * communication is always request / response based. That means that this packet is
+ * a response packet and it will only be sent, after the reception of a request packet.
+ *
+ * A response packet is only deemed valid, after the T3_5 idle time. This module
+ * implements the T3_5 end-of-packet time event detection. Consequently, it is already
+ * guaranteed that there is T3_5 between subsequent packet transmissions. As such, no
+ * further T3_5 wait time is needed here.
+ */
+
+ /* verify validity of the len-parameter */
+ ASSERT_RT(len <= BOOT_COM_MBRTU_TX_MAX_DATA);
+
+ /* construct the Modbus RTU packet. start by adding the slave address. */
+ txPacket[0] = BOOT_COM_MBRTU_NODE_ID;
+ /* add the user-defined function code for embedding XCP packets. */
+ txPacket[1] = BOOT_COM_MBRTU_FCT_CODE_USER_XCP;
+ /* add the XCP packet length. */
+ txPacket[2] = len;
+
+ /* copy the XCP packet data. */
+ CpuMemCopy((blt_int32u)&txPacket[3], (blt_int32u)data, len);
+ /* calculate the checksum for the packet, including slave address, function code and
+ * extra XCP length.
+ */
+ checksum = MbRtuCrcCalculate(&txPacket[0], len + 3);
+ /* add the checksum at the end of the packet */
+ txPacket[len + 3] = (blt_int8u)(checksum & 0xff);
+ txPacket[len + 4] = (blt_int8u)(checksum >> 8);
+
+ /* enable the driver output to be able to send. just make sure to wait a little around
+ * the togglng of the DE/NRE pin.
+ */
+ MbRtuDelay(BOOT_COM_MBRTU_DRIVER_OUTPUT_ENABLE_DELAY_US);
+ MbRtuDriverOutputControlHook(BLT_TRUE);
+ MbRtuDelay(BOOT_COM_MBRTU_DRIVER_OUTPUT_ENABLE_DELAY_US);
+
+ /* transmit all the packet bytes one-by-one */
+ for (data_index = 0; data_index < (len + 5); data_index++)
+ {
+ /* keep the watchdog happy */
+ CopService();
+ /* last byte of the packet? */
+ if (data_index == ((len + 5) - 1))
+ {
+ /* update the end of packet flag. */
+ endOfPacket = BLT_TRUE;
+ }
+ /* write byte */
+ MbRtuTransmitByte(txPacket[data_index], endOfPacket);
+ }
+ /* enable the receiver output to be able to receive again. just make sure to wait a
+ * little around the togglng of the DE/NRE pin.
+ */
+ MbRtuDelay(BOOT_COM_MBRTU_DRIVER_OUTPUT_DISABLE_DELAY_US);
+ MbRtuDriverOutputControlHook(BLT_FALSE);
+ MbRtuDelay(BOOT_COM_MBRTU_DRIVER_OUTPUT_DISABLE_DELAY_US);
+} /*** end of MbRtuTransmitPacket ***/
+
+
+/************************************************************************************//**
+** \brief Receives a communication interface packet if one is present.
+** \param data Pointer to byte array where the data is to be stored.
+** \param len Pointer where the length of the packet is to be stored.
+** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
+**
+****************************************************************************************/
+blt_bool MbRtuReceivePacket(blt_int8u *data, blt_int8u *len)
+{
+ blt_bool result = BLT_FALSE;
+ blt_int8u rxByte;
+ blt_int16u currentTimeTicks;
+ blt_int16u deltaTimeTicks;
+ blt_int16u checksumCalculated;
+ blt_int16u checksumReceived;
+ /* Made static to lower stack load and +5 for Modbus RTU packet overhead. */
+ static blt_int8u rxPacket[BOOT_COM_MBRTU_RX_MAX_DATA + 5];
+ static blt_int8u rxLength = 0;
+ static blt_bool packetRxInProgress = BLT_FALSE;
+ static blt_int16u lastRxByteTimeTicks = 0;
+
+ /* get the current value of the free running counter. */
+ currentTimeTicks = MbRtuFreeRunningCounterGet();
+
+ /* check for a newly received byte. */
+ if (MbRtuReceiveByte(&rxByte) == BLT_TRUE)
+ {
+ /* store the time at which the byte was received. */
+ lastRxByteTimeTicks = currentTimeTicks;
+ /* is this the potential start of a new packet? */
+ if (packetRxInProgress == BLT_FALSE)
+ {
+ /* initialize the reception of a new packet. */
+ rxLength = 0;
+ packetRxInProgress = BLT_TRUE;
+ }
+ /* store the newly received byte in the buffer, with buffer overrun protection. */
+ if (rxLength < (sizeof(rxPacket)/sizeof(rxPacket[0])))
+ {
+ rxPacket[rxLength] = rxByte;
+ rxLength++;
+ }
+ /* buffer overrun occurred. received packet was longer than supported so discard
+ * the packet to try and sync to the next one.
+ */
+ else
+ {
+ /* discard the partially received packet. */
+ packetRxInProgress = BLT_FALSE;
+ }
+ }
+
+ /* only attempt to detect the end of packet, when a reception is in progress. */
+ if (packetRxInProgress == BLT_TRUE)
+ {
+ /* calculate the number of ticks that elapsed since the last byte reception. note
+ * that this calculation works, even if the free running counter overflowed.
+ */
+ deltaTimeTicks = currentTimeTicks - lastRxByteTimeTicks;
+ /* packet reception is assumed complete after T3_5 of not receiving new data. */
+ if (deltaTimeTicks >= mbRtuT3_5Ticks)
+ {
+ /* a Modbus RTU packet consists of at least the address field, function code and
+ * 16-bit CRC. Validate the packet length based on this info.
+ */
+ if (rxLength >= 4)
+ {
+ /* calculate the packet checksum. */
+ checksumCalculated = MbRtuCrcCalculate(&rxPacket[0], rxLength - 2);
+ /* extract the checksum received with the packet. */
+ checksumReceived = rxPacket[rxLength - 2] | (rxPacket[rxLength - 1] << 8);
+ /* only continue with packet processing if the checksums match. */
+ if (checksumCalculated == checksumReceived)
+ {
+ /* we are only interested in Modbus RTU packets that are addressed to us and
+ * have an XCP packet embedded.
+ */
+ if ( (rxPacket[0] == BOOT_COM_MBRTU_NODE_ID) &&
+ (rxPacket[1] == BOOT_COM_MBRTU_FCT_CODE_USER_XCP) )
+ {
+ /* An XCP packet embedded in a Modbus RTU packet has an extra XCP packet
+ * length value. Use it to double-check that the packet length is valid.
+ */
+ if (rxPacket[2] == (rxLength - 5))
+ {
+ /* copy the packet's XCP data. */
+ CpuMemCopy((blt_int32u)data, (blt_int32u)&rxPacket[3], rxLength - 5);
+ /* set the packet's XCP length. */
+ *len = rxLength - 5;
+ /* update the result to success to indicate that this XCP packet is ready
+ * for processing.
+ */
+ result = BLT_TRUE;
+ }
+ }
+ }
+ }
+ /* reset the packet reception in progress flag, to be able to receive the next. */
+ packetRxInProgress = BLT_FALSE;
+ }
+ }
+
+ /* give the result back to the caller. */
+ return result;
+} /*** end of MbRtuReceivePacket ***/
+
+
+/************************************************************************************//**
+** \brief Receives a communication interface byte if one is present.
+** \param data Pointer to byte where the data is to be stored.
+** \return BLT_TRUE if a byte was received, BLT_FALSE otherwise.
+**
+****************************************************************************************/
+static blt_bool MbRtuReceiveByte(blt_int8u *data)
+{
+ blt_bool result = BLT_FALSE;
+ blt_int32u data_and_status;
+
+ /* wait for the reception of a new byte. */
+ if (XMC_USIC_CH_RXFIFO_IsEmpty(MBRTU_CHANNEL) == 0)
+ {
+ /* update the result */
+ result = BLT_TRUE;
+ /* read out the newly received data, including its PERR status flags */
+ data_and_status = MBRTU_CHANNEL->OUTR;
+ /* check for a frame error. the frame error check is important because it can detect
+ * a missing stopbit. on an RS485 bus without bias resistors, the A-B differential
+ * voltage is 0. for an RS485 transceiver this is neither a 0 nor a 1 bit, so
+ * undefined. most RS485 transceivers feature a reception failsafe function to drive
+ * the Rx output (going to the UART Rx) to a defined state of logic 1. in case the
+ * used RS485 transceiver doesn't have such a feature, it typically leaves the Rx
+ * output in a logic 0 state. this means that after the stop bit of the last packet
+ * byte, the UART Rx input sees a logic 0, and assumes it is a start bit. the
+ * remaining data bits will always be 0 and, most importantly no stop bit is
+ * present, causing a framing error. Long story short: if you don't check for the
+ * framing error flag, you might receive an extra byte with value 0, which is not
+ * actually transmitted on the RS485 bus. you can catch and ignore this byte by doing
+ * a frame error check.
+ */
+ if( (XMC_UART_CH_GetStatusFlag(MBRTU_CHANNEL) &
+ (XMC_UART_CH_STATUS_FLAG_FORMAT_ERROR_IN_STOP_BIT_0 |
+ XMC_UART_CH_STATUS_FLAG_FORMAT_ERROR_IN_STOP_BIT_1)) != 0)
+ {
+ /* clear the error flags. */
+ XMC_UART_CH_ClearStatusFlag(MBRTU_CHANNEL,
+ XMC_UART_CH_STATUS_FLAG_FORMAT_ERROR_IN_STOP_BIT_0 |
+ XMC_UART_CH_STATUS_FLAG_FORMAT_ERROR_IN_STOP_BIT_1);
+ /* ignore the byte because of a detected frame error. */
+ result = BLT_FALSE;
+ }
+ #if (BOOT_COM_MBRTU_PARITY > 0)
+ /* check if a parity error was detected (PERR is RCI[4]). */
+ if ((data_and_status & 0x00100000UL) != 0)
+ {
+ /* ignore the byte because of a detected parity error. */
+ result = BLT_FALSE;
+ }
+ #endif
+ /* store the newly received byte by casting it to exclude the status flags. */
+ *data = (blt_int8u)data_and_status;
+ }
+ /* give the result back to the caller */
+ return result;
+} /*** end of MbRtuReceiveByte ***/
+
+
+/************************************************************************************//**
+** \brief Transmits a communication interface byte.
+** \param data Value of byte that is to be transmitted.
+** \param end_of_packet BLT_TRUE if this is the last byte of the packet, BLT_FALSE
+** otherwise.
+** \return none.
+**
+****************************************************************************************/
+static void MbRtuTransmitByte(blt_int8u data, blt_bool end_of_packet)
+{
+ blt_int32u timeout;
+
+ /* clear the status flag that indicates that a frame (byte) finished transmission. */
+ XMC_UART_CH_ClearStatusFlag(MBRTU_CHANNEL, XMC_UART_CH_STATUS_FLAG_TRANSMITTER_FRAME_FINISHED);
+ /* submit data for transmission. it will be placed in the Tx FIFO and will
+ * automatically be moved to the transmit shift register, when this one is no longer
+ * busy.
+ */
+ XMC_UART_CH_Transmit(MBRTU_CHANNEL, data);
+ /* set timeout time to wait for transmit completion. */
+ timeout = TimerGet() + MBRTU_BYTE_TX_TIMEOUT_MS;
+
+ /* not the last byte of the packet? */
+ if (end_of_packet == BLT_FALSE)
+ {
+ /* wait for the Tx FIFO fill level to be below its configured limit of 1. this
+ * means the Tx FIFO is empty and the to-be-transmitted byte is now in the transmit
+ * shift register.
+ */
+ while( (XMC_USIC_CH_TXFIFO_GetEvent(MBRTU_CHANNEL) & XMC_USIC_CH_TXFIFO_EVENT_STANDARD) == 0)
+ {
+ /* keep the watchdog happy. */
+ CopService();
+ /* break loop upon timeout. this would indicate a hardware failure. */
+ if (TimerGet() > timeout)
+ {
+ break;
+ }
+ }
+ /* reset event */
+ XMC_USIC_CH_TXFIFO_ClearEvent(MBRTU_CHANNEL, XMC_USIC_CH_TXFIFO_EVENT_STANDARD);
+ }
+ /* this is the last byte of a packet. */
+ else
+ {
+ /* wait for transmit frame finished flag to be set, indicating that the last byte has
+ * left the transmit shift register, including the stopbit(s). this is needed for the
+ * last byte, otherwise the transceiver's transmit output gets disabled with
+ * MbRtuDriverOutputControlHook() before the byte reception completes.
+ */
+ while( (XMC_UART_CH_GetStatusFlag(MBRTU_CHANNEL) & XMC_UART_CH_STATUS_FLAG_TRANSMITTER_FRAME_FINISHED) == 0)
+ {
+ /* keep the watchdog happy. */
+ CopService();
+ /* break loop upon timeout. this would indicate a hardware failure. */
+ if (TimerGet() > timeout)
+ {
+ break;
+ }
+ }
+ }
+} /*** end of MbRtuTransmitByte ***/
+
+
+/************************************************************************************//**
+** \brief Obtains the counter value of the 100 kHz free running counter. Note that
+** each count represent 10 us. The Modbus RTU communication module uses this
+** free running counter for Modbus RTU packet timing related purposes. The
+** already available 1 ms timer does not have the needed resolution for this
+** purpose.
+** \return Current value of the free running counter.
+**
+****************************************************************************************/
+blt_int16u MbRtuFreeRunningCounterGet(void)
+{
+ static blt_bool initialized = BLT_FALSE;
+ static blt_int32u counts_per_ten_us = 0;
+ static blt_int32u free_running_counter_last = 0;
+ static blt_int16u ten_us_tick_counter = 0;
+ blt_int32u free_running_counter_now;
+ blt_int32u delta_counts;
+ blt_int32u ten_us_ticks;
+
+ /* perform one-time initialization.*/
+ if (initialized == BLT_FALSE)
+ {
+ /* set the flag to make sure that this part only runs once. */
+ initialized = BLT_TRUE;
+ /* calculate how many counts of the SysTick's free running counter equals 10us,
+ * because one count of a 100 kHz counter equals that. Note that the timer module
+ * already initialized and enable the SysTick.
+ */
+ counts_per_ten_us = SystemCoreClock / 100000U;
+ /* initialize current value of the timer's free running counter. */
+ free_running_counter_last = (SysTick->VAL & SysTick_VAL_CURRENT_Msk);
+ }
+
+ /* get the current value of the free running counter. */
+ free_running_counter_now = (SysTick->VAL & SysTick_VAL_CURRENT_Msk);
+ /* Calculate the number of counts that passed since the detection of the last
+ * millisecond event. Keep in mind that the SysTick has a down-counting 24-bit free
+ * running counter. Note that this calculation also works, in case the free running
+ * counter overflowed, thanks to integer math.
+ */
+ delta_counts = free_running_counter_last - free_running_counter_now;
+ delta_counts &= SysTick_VAL_CURRENT_Msk;
+
+ /* did one or more ten microsecond counts pass since the last event? */
+ if (delta_counts >= counts_per_ten_us)
+ {
+ /* calculate how many ten microsecond counts passed. */
+ ten_us_ticks = delta_counts / counts_per_ten_us;
+ /* update the counter. */
+ ten_us_tick_counter += ten_us_ticks;
+ /* store the counter value of the last event to detect the next one. */
+ free_running_counter_last -= (ten_us_ticks * counts_per_ten_us);
+ free_running_counter_last &= SysTick_VAL_CURRENT_Msk;
+ }
+
+ /* return the current value of the 100 kHz free running counter to the caller. */
+ return ten_us_tick_counter;
+} /*** end of MbRtuFreeRunningCounterGet ***/
+#endif /* BOOT_COM_MBRTU_ENABLE > 0 */
+
+/*********************************** end of mbrtu.c ************************************/
diff --git a/Target/Source/ARMCM4_XMC4/rs232.c b/Target/Source/ARMCM4_XMC4/rs232.c
index 45927573..b02a1b16 100644
--- a/Target/Source/ARMCM4_XMC4/rs232.c
+++ b/Target/Source/ARMCM4_XMC4/rs232.c
@@ -30,10 +30,10 @@
* Include files
****************************************************************************************/
#include "boot.h" /* bootloader generic header */
+#if (BOOT_COM_RS232_ENABLE > 0)
#include "xmc_uart.h" /* UART driver header */
-#if (BOOT_COM_RS232_ENABLE > 0)
/****************************************************************************************
* Macro definitions
****************************************************************************************/
@@ -86,7 +86,7 @@ void Rs232Init(void)
XMC_UART_CH_CONFIG_t uart_config;
/* the current implementation supports XMC_UART0_CH0 to XMC_UART2_CH1. throw an
- * assertion error in case a different CAN channel is configured.
+ * assertion error in case a different UART channel is configured.
*/
ASSERT_CT((BOOT_COM_RS232_CHANNEL_INDEX >= 0) && (BOOT_COM_RS232_CHANNEL_INDEX <= 5));
diff --git a/Target/Source/ARMCM4_XMC4/timer.c b/Target/Source/ARMCM4_XMC4/timer.c
index 5628473c..d4573bbc 100644
--- a/Target/Source/ARMCM4_XMC4/timer.c
+++ b/Target/Source/ARMCM4_XMC4/timer.c
@@ -30,29 +30,7 @@
* Include files
****************************************************************************************/
#include "boot.h" /* bootloader generic header */
-
-
-/****************************************************************************************
-* Type definitions
-****************************************************************************************/
-/** \brief Systick registers. */
-typedef struct
-{
- volatile blt_int32u CTRL; /**< SysTick Control and Status Register */
- volatile blt_int32u LOAD; /**< SysTick Reload Value Register */
- volatile blt_int32u VAL; /**< SysTick Current Value Register */
-} tSysTickRegs;
-
-
-/****************************************************************************************
-* Macro definitions
-****************************************************************************************/
-/** \brief CLKSOURCE bit of the system tick. */
-#define SYSTICK_BIT_CLKSOURCE ((blt_int32u)0x00000004)
-/** \brief ENABLE bit of the system tick. */
-#define SYSTICK_BIT_ENABLE ((blt_int32u)0x00000001)
-/** \brief COUNTERFLAG bit of the system tick. */
-#define SYSTICK_BIT_COUNTERFLAG ((blt_int32u)0x00010000)
+#include "xmc_common.h" /* common vendor library definitions */
/****************************************************************************************
@@ -63,31 +41,41 @@ typedef struct
*/
static blt_int32u millisecond_counter;
+/** \brief Buffer for storing the last value of the free running counter. */
+static blt_int32u free_running_counter_last;
-/****************************************************************************************
-* Register definitions
-****************************************************************************************/
-/** \brief Macro to access the system tick registers. */
-#define SYSTICK ((tSysTickRegs *) (blt_int32u)0xE000E010)
+/** \brief Stores the number of counts of the free running counter that equals one
+ * millisecond.
+ */
+static blt_int32u counts_per_millisecond;
/************************************************************************************//**
** \brief Initializes the polling based millisecond timer driver.
+** \details Ideally a 100 kHz free running counter is used as the foundation for the
+** timer modules, as this gives 10us ticks that can be reused by other
+** modules. The XMC4 timers unfortunately do not offer a flexible prescaler
+** for their timers to realize such a 100 kHz free running counter. For this
+** reason, the SysTick counter is used instead. Its 24-bit free running
+** down-counter runs at the system speed.
** \return none.
**
****************************************************************************************/
void TimerInit(void)
{
- /* reset the timer configuration */
+ /* Reset the timer configuration. */
TimerReset();
- /* configure the systick frequency as a 1 ms event generator */
- SYSTICK->LOAD = BOOT_CPU_SYSTEM_SPEED_KHZ - 1;
- /* reset the current counter value */
- SYSTICK->VAL = 0;
- /* select core clock as source and enable the timer */
- SYSTICK->CTRL = SYSTICK_BIT_CLKSOURCE | SYSTICK_BIT_ENABLE;
- /* reset the millisecond counter value */
+ /* Configure the reload value such that the full 24-bit range is used. */
+ SysTick->LOAD = (0xFFFFFFFFUL & SysTick_LOAD_RELOAD_Msk);
+ /* Reset the current counter value. */
+ SysTick->VAL = 0UL;
+ /* Select core clock as source and enable the timer. */
+ SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk;
+ /* Calculate how many counts equal 1 millisecond. */
+ counts_per_millisecond = SystemCoreClock/1000U;
+ /* Initialize remaining locals. */
millisecond_counter = 0;
+ free_running_counter_last = (SysTick->VAL & SysTick_VAL_CURRENT_Msk);
} /*** end of TimerInit ***/
@@ -99,11 +87,11 @@ void TimerInit(void)
****************************************************************************************/
void TimerReset(void)
{
- /* set the systick's registers back into the default reset value */
- SYSTICK->CTRL = 0;
- SYSTICK->LOAD = 0;
- SYSTICK->VAL = 0;
-} /* end of TimerReset */
+ /* Set the systick's registers back into the default reset value. */
+ SysTick->CTRL = 0UL;
+ SysTick->LOAD = 0UL;
+ SysTick->VAL = 0UL;
+} /*** end of TimerReset ***/
/************************************************************************************//**
@@ -113,11 +101,30 @@ void TimerReset(void)
****************************************************************************************/
void TimerUpdate(void)
{
- /* check if the millisecond event occurred */
- if ((SYSTICK->CTRL & SYSTICK_BIT_COUNTERFLAG) != 0)
+ blt_int32u free_running_counter_now;
+ blt_int32u delta_counts;
+ blt_int32u ms_counts;
+
+ /* Get the current value of the free running counter. */
+ free_running_counter_now = (SysTick->VAL & SysTick_VAL_CURRENT_Msk);
+ /* Calculate the number of counts that passed since the detection of the last
+ * millisecond event. Keep in mind that the SysTick has a down-counting 24-bit free
+ * running counter. Note that this calculation also works, in case the free running
+ * counter overflowed, thanks to integer math.
+ */
+ delta_counts = free_running_counter_last - free_running_counter_now;
+ delta_counts &= SysTick_VAL_CURRENT_Msk;
+
+ /* Did one or more milliseconds pass since the last event? */
+ if (delta_counts >= counts_per_millisecond)
{
- /* increment the millisecond counter */
- millisecond_counter++;
+ /* Calculate how many milliseconds passed. */
+ ms_counts = delta_counts / counts_per_millisecond;
+ /* Update the millisecond counter. */
+ millisecond_counter += ms_counts;
+ /* Store the counter value of the last millisecond event, to detect the next one. */
+ free_running_counter_last -= (ms_counts * counts_per_millisecond);
+ free_running_counter_last &= SysTick_VAL_CURRENT_Msk;
}
} /*** end of TimerUpdate ***/
@@ -129,11 +136,11 @@ void TimerUpdate(void)
****************************************************************************************/
blt_int32u TimerGet(void)
{
- /* updating timer here allows this function to be called in a loop with timeout
+ /* Updating timer here allows this function to be called in a loop with timeout
* detection.
*/
TimerUpdate();
- /* read and return the amount of milliseconds that passed since initialization */
+ /* Read and return the amount of milliseconds that passed since initialization. */
return millisecond_counter;
} /*** end of TimerGet ***/