问题的提出
用KEIL进行软件仿真,想观察一下处理器STM32F091RCY的I2C和DAC引脚输出的波形,发现无法向波形中添加信号,如下图所示
当在命令行中输入 dir vtreg 指令时,仅仅能够显示内核的寄存器,外设的寄存器无法输出:
dir vtreg
CURR_TID: ulong, value = 0x00000000
TRAPS: ulong, value = 0x00000000
TRIGFLT: ulong, value = 0x00000000
STCLK: ulong, value = 0x00000000
XTAL: ulong, value = 0x007A1200
CLOCK: ulong, value = 0x007A1200
网上寻找答案,发现所有的关于软件逻辑分析仪的示例都是用器件STM32F103
问题的答案
KEIL5仅对某些器件的外设支持仿真,KEIL官方给出了网站
,在该网页中,列出了支持软件仿真的器件,如:
- 对于STMicroexectronics公司的处理器,仅支持STM32F101和STM32F103.
- 对于NXP公司的处理器,仅支持LPC1111, LPC1112, LPC1113, LPC1114四个系列.
这也难怪,网上给出的KEIL的软件逻辑分析仪的仿真示例都是用STM32F103这个器件。
问题的解决
为了仿真I2C的程序段,在STM32CUBE MX中,将器件改为STM32F103C8,重新进行仿真,在Option for Target中的Debug中,按下图进行设置:
进入debug界面,在命令行中输入DIR VTREG, 显示出外设的寄存器:
DIR VTREG
CURR_TID: ulong, value = 0x00000000
TRAPS: ulong, value = 0x00000000
TRIGFLT: ulong, value = 0x00000000
STCLK: ulong, value = 0x000F4240
OSC: ulong, value = 0x007A1200
SYSCLK: ulong, value = 0x007A1200
HSI_RC: ulong, value = 0x007A1200
OSC32: ulong, value = 0x00008000
LSI_RC: ulong, value = 0x00008000
HCLK: ulong, value = 0x007A1200
PCLK1: ulong, value = 0x007A1200
PCLK2: ulong, value = 0x007A1200
RTCCLK: ulong, value = 0x00008000
IWDGCLK: ulong, value = 0x00008000
USBCLK: ulong, value = 0x007A1200
ADCCLK: ulong, value = 0x003D0900
TIMXCLK: ulong, value = 0x007A1200
TIM1CLK: ulong, value = 0x007A1200
BOOT: uchar, value = 0x00
PORTA: ushort, value = 0x0000
PORTB: ushort, value = 0x0000
PORTC: ushort, value = 0x0000
PORTD: ushort, value = 0x0000
S1IN: ushort, value = 0xFFFF
S1OUT: ushort, value = 0x0000
S1TIME: uchar, value = 0x01
S2IN: ushort, value = 0xFFFF
S2OUT: ushort, value = 0x0000
S2TIME: uchar, value = 0x01
S3IN: ushort, value = 0xFFFF
S3OUT: ushort, value = 0x0000
S3TIME: uchar, value = 0x01
SPI1_IN: ushort, value = 0x0000
SPI1_OUT: ushort, value = 0x0000
SPI2_IN: ushort, value = 0x0000
SPI2_OUT: ushort, value = 0x0000
I2C1_IN: ushort, value = 0xFFFF
I2C1_OUT: ushort, value = 0xFFFF
I2C2_IN: ushort, value = 0xFFFF
I2C2_OUT: ushort, value = 0xFFFF
CAN1ID: ulong, value = 0x00000000
CAN1L: uchar, value = 0x00
CAN1B0: uchar, value = 0x00
CAN1B1: uchar, value = 0x00
CAN1B2: uchar, value = 0x00
CAN1B3: uchar, value = 0x00
CAN1B4: uchar, value = 0x00
CAN1B5: uchar, value = 0x00
CAN1B6: uchar, value = 0x00
CAN1B7: uchar, value = 0x00
CAN1IN: ushort, value = 0x0000
CAN1OUT: ushort, value = 0x0000
ADC1_IN0: float, value = 0
ADC1_IN1: float, value = 0
ADC1_IN2: float, value = 0
ADC1_IN3: float, value = 0
ADC1_IN4: float, value = 0
ADC1_IN5: float, value = 0
ADC1_IN6: float, value = 0
ADC1_IN7: float, value = 0
ADC1_IN8: float, value = 0
ADC1_IN9: float, value = 0
ADC1_IN10: float, value = 0
ADC1_IN11: float, value = 0
ADC1_IN12: float, value = 0
ADC1_IN13: float, value = 0
ADC1_IN14: float, value = 0
ADC1_IN15: float, value = 0
VTEMP1: float, value = 3.29999995
VREFINT: float, value = 3.29999995
VREFP: float, value = 3.29999995
VREFN: float, value = 0
ADC2_IN0: float, value = 0
ADC2_IN1: float, value = 0
ADC2_IN2: float, value = 0
ADC2_IN3: float, value = 0
ADC2_IN4: float, value = 0
ADC2_IN5: float, value = 0
ADC2_IN6: float, value = 0
ADC2_IN7: float, value = 0
ADC2_IN8: float, value = 0
ADC2_IN9: float, value = 0
ADC2_IN10: float, value = 0
ADC2_IN11: float, value = 0
ADC2_IN12: float, value = 0
ADC2_IN13: float, value = 0
ADC2_IN14: float, value = 0
ADC2_IN15: float, value = 0
VTEMP2: float, value = 3.29999995
同时,也可以向软件逻辑分析仪中添加信号了。