2321 views|4 replies

1w

Posts

16

Resources
The OP
 

[Qinheng Trial] Single-step simulation [Copy link]

 

I remember that the STC microcontroller has a chip that can be used for single-step simulation. I didn't expect Qinheng to be able to do it, so I tried it today and it works well.

It’s actually very simple:

1. Add ISD51.A51 and ISD51.H to the project;

2. Initialize the serial port, configure the appropriate baud rate, and finally enable the global interrupt;

3. Select the appropriate ISD51 initialization function;

ISDinit(): Initialize and run the user program. If KEIL successfully communicates with the microcontroller, the program will terminate immediately.

ISDwait(): Initialize ISD51 and wait for KEIL to connect

ISDcheck(): Periodically check the ISD51 connection

4. Compile the user program and burn it into the microcontroller;

5. Select ISD51 In-system Debugger in KEIL -> option for target -> DEBUG setting, and set the serial port baud rate corresponding to the ISD51 serial port initialization in setup.

6. Click the DEBUG button to enter hardware debugging mode.

ISD51 interface functions can be found in the KEIL help document.

Is that really the case?

I modified the ID reading program in the simulation routine:


#include	"CH554.H"
#include	"debug.h"
#include	"STDIO.H"
//#include	<absacc.h>										/* Direct access to memory areas. */
#include 	"ISD51.H"										/* Find it at the location like 'C:\Keil\C51\ISD51' */

UINT8 str[] = "hello CH55X!\n";
UINT8 t = 0;
sbit LED	= P1^0;


#define ROM_CHIP_ID_ADDR 0x20

/*******************************************************************************
* Function Name  : GetChipID(void)
* Description    : 获取ID号和ID号和校验
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
UINT32 GetChipID( void )
{
	UINT8	d0, d1;
	UINT16	xl, xh;
	E_DIS = 1;                                                                  //避免进入中断
	d0 = *(PUINT8C)( ROM_CHIP_ID_ADDR + 0 );
	d1 = *(PUINT8C)( ROM_CHIP_ID_ADDR + 1 );                                    //ID号低字
	xl = ( d1 << 8 ) | d0;
	d0 = *(PUINT8C)( ROM_CHIP_ID_ADDR + 2 );
	d1 = *(PUINT8C)( ROM_CHIP_ID_ADDR + 3 );                                    //ID号高字
	xh = ( d1 << 8 ) | d0;
	d0 = *(PUINT8C)( ROM_CHIP_ID_ADDR + 6 );
	d1 = *(PUINT8C)( ROM_CHIP_ID_ADDR + 7 );                                    //ID校验和
	E_DIS = 0;
	if ( (UINT16)( xl + xh ) != (UINT16)( ( d1 << 8 ) | d0 ) ) return( 0xFFFFFFFF );//校验ID号
	return( ( (UINT32)xh << 16 ) | xl );
}

/*******************************************************************************
* Function Name  : CopyChipID(void)
* Description    : 获取ID号,因为Flash双字节访问,低字节在前,使用时要注意
* Input          : PUINT32X buf
* Output         : None
* Return         : None
*******************************************************************************/
void CopyChipID( PUINT32X buf )
{
	E_DIS = 1;
	*( (PUINT16X)buf + 0 ) = *(const unsigned short code *)( ROM_CHIP_ID_ADDR + 0 );
	*( (PUINT16X)buf + 1 ) = *(const unsigned short code *)( ROM_CHIP_ID_ADDR + 2 );
	E_DIS = 0;
}


void main( void )
{
	UINT32 x;
	CfgFsys();
	mDelaymS(10);
	mInitSTDIO();											/* Baudrate = 57600, 8, 1, N */
	EA = 1;
	printf("INIT OK!\n");
	printf("%s",str);
	ISDwait();												/* Wait until Debugger sends 0xA5, comment it if not nessery. */
	while(1)
	{
		t++;												/* Add t to watch windos, this can be changged by manual. */
		ISDcheck();											/* Wait util Debugger send 0xA5, if ISD51 UART already initialized. */
		LED ^= 1;											/* Toggle P1^0 bit. */
		mDelaymS(10);	
		CopyChipID(&x);
        printf("ID:%lx\n",x);	
	}


}

The simulation results are as follows:

I think the simulation of Biheng is better. It doesn't cost anything. Just test two programs and arrange the functions.

Attached simulation routine:

1507967901967569.rar (159.06 KB, downloads: 8)




This content is originally created by EEWORLD forum user ddllxxrr . If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source

This post is from Domestic Chip Exchange

Latest reply

Like . CH554 has many more functions. I look forward to your further exploration and sharing.   Details Published on 2019-7-8 09:28
Personal signaturehttp://shop34182318.taobao.com/
https://shop436095304.taobao.com/?spm=a230r.7195193.1997079397.37.69fe60dfT705yr
 
 

367

Posts

0

Resources
2
 

Anyone still using XP?

This post is from Domestic Chip Exchange

Comments

Yes, our company uses XP. Why? As long as it works, it's fine.  Details Published on 2019-7-7 20:26
Personal signature拿PADS和Allegro软件来吹牛的都是些土鳖
 
 
 

1w

Posts

16

Resources
3
 
lingking posted on 2019-7-7 13:28 Does anyone still use XP

Yes, our company uses XP. Why? As long as it works, it's fine.

This post is from Domestic Chip Exchange

Comments

Many design software no longer supports XP  Details Published on 2019-7-7 20:41
Personal signaturehttp://shop34182318.taobao.com/
https://shop436095304.taobao.com/?spm=a230r.7195193.1997079397.37.69fe60dfT705yr
 
 
 

367

Posts

0

Resources
4
 
ddllxxrr posted on 2019-7-7 20:26 Yes, my company uses XP, why? ? ? ? As long as it can work, it's fine.

Many design software no longer supports XP

This post is from Domestic Chip Exchange
Personal signature拿PADS和Allegro软件来吹牛的都是些土鳖
 
 
 

45

Posts

0

Resources
5
 

Like . CH554 has many more functions. I look forward to your further exploration and sharing.

This post is from Domestic Chip Exchange
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list