单片机语言硬件信息PLC(测试单片机信息自己的参数)「单片机性能测试」

信捷PLC的编译过程由arm-none-eabi处理,加上C语言的高自由度,基本上可以当成大号单片机使用了
以下程序实现了单片机一些硬件信息的获取,源码及测试结果请大家参考
有兴趣测试的朋友,请贴上自己的测试结果吧
/ FunctionBlockName: CPUINFO Version: 1.0.0 Author: thj UpdateTime: 2021-12-01 00:00:00 Comment: 取得CPU信息:参数W 结果存放地址,双字无符号型参数M 信息类型 M0_DeviceInfo 16位版本|4位保留|12位类型 M1_CpuFrequency kHz M2_FlashSize KB 其它_0xCCCCCCCC/#define W32U ((PINT32U)W)extern char __M;void CPUINFO ( WORD W, BIT B ){ static INT32U deviceInfo; static INT32U cpuFrequency; static INT32U flashSize; static INT8U inited; if ( !inited ) { inited = 1; asm ( "svc 0x01" ); //提升权限 deviceInfo = ( PINT32U ) 0xE0042000; //X5D-24 STM32F4: 1007(Rev2) 6(Reserved) 413 //XL5E-16 STM32F7: 1001(RevZ) 6(Reserved) 451 cpuFrequency = ( PINT32U ) 0xE000E014 + 1; //1ms计时初值,主频=(x+1)1000Hz //https://github.com/MaJerle/stm32fxxx-hal-libraries/blob/master/00-STM32_LIBRARIES/tm_stm32_id.h switch ( deviceInfo & 0xfff ) { case 0x444: //STM32F0 3xxx case 0x445: //STM32F0 4xxx case 0x440: //STM32F0 5xxx case 0x448: //STM32F0 7xxx case 0x442: //STM32F0 9xxx flashSize = ( PINT16U ) 0x1FFFF7CC; //STM32F0 xxxx break; case 0x413: //STM32F4 05xx/07xx/15xx/17xx, X5D-24 07Zx 1024KB case 0x423: //STM32F4 01xB/C case 0x433: //STM32F4 01xD/E case 0x431: //STM32F4 11xC/E case 0x419: //STM32F4 2xxx/3xxx case 0x421: //STM32F4 46xx flashSize = ( PINT16U ) 0x1FFF7A22; //STM32F4 xxxx break; case 0x449: //STM32F7 x6xx case 0x451: //STM32F7 6xxx/7xxx, XL5E-16 65xI 2048KB flashSize = ( PINT16U ) 0x1FF0F442; //STM32F7 xxxx break; default: flashSize = 0; break; } } INT32U v; INT32U typeID = ( ( INT32U ) B - ( INT32U ) ( &__M ) ) / sizeof ( ARM_BIT ); switch ( typeID ) { case 0: v = deviceInfo; break; case 1: v = cpuFrequency; break; case 2: v = flashSize; break; default: v = 0xCCCCCCCC; } if ( v != W32U ) W32U = v;};测试程序LDPM3CPUINFOD10M0CPUINFOD12M1CPUINFOD14M2;自由监控 测试设备 XD5-24D1010076413 双字 16进制 DeviceInfoD12168000 双字 10进制 CpuFrequency kHzD141024 双字 10进制 FlashSize KB;自由监控 测试设备 XL5E-16D1010016451 双字 16进制 DeviceInfoD12216000 双字 10进制 CpuFrequency kHzD142048 双字 10进制 FlashSize KB
单片机语言硬件信息PLC(测试单片机信息自己的参数)
(图片来源网络,侵删)

联系我们

在线咨询:点击这里给我发消息