Hi, I just created a function in uVision that puts into a pretty tight knot. Take a look at the following modified Dbg_Sim.ini from the CAN demo. When the Test button is pressed in the toolbox, uVision prompts for a number, then immediately prompts for the number again. From then on, uVision does nothing at all other than insist on a number input. It appears to be impossible to break out of this, requires going to the Windows Task Manager and killing uVision. There should be a way to get uVision to cleanly break out of such a condition. Thanks, Dan
/*---------------------------------------------------------------------------- * Name: Dbg_Sim.ini * Purpose: Simulator Debug Initialization File * Note(s): *---------------------------------------------------------------------------- * This file is part of the uVision/ARM development tools. * This software may only be used under the terms of a valid, current, * end user licence from KEIL for a compatible version of KEIL software * development tools. Nothing else gives you the right to use this software. * * This software is supplied "AS IS" without warranties of any kind. * * Copyright (c) 2008-2011 Keil - An ARM Company. All rights reserved. *----------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------- CAN_loopback_1_to_2() simulates loopback connection from CAN1 to CAN2 port *----------------------------------------------------------------------------*/
signal void CAN_loopback_1_to_2 (void) { while (1) { wwatch(CAN1OUT); CAN2ID = CAN1ID; CAN2B0 = CAN1B0; CAN2B1 = CAN1B1; CAN2B2 = CAN1B2; CAN2B3 = CAN1B3; CAN2B4 = CAN1B4; CAN2B5 = CAN1B5; CAN2B6 = CAN1B6; CAN2B7 = CAN1B7; CAN2L = CAN1L; CAN2IN = CAN1OUT; } }
/*---------------------------------------------------------------------------- CAN_loopback_2_to_1() simulates loopback connection from CAN2 to CAN1 port *----------------------------------------------------------------------------*/
signal void CAN_loopback_2_to_1 (void) { while (1) { wwatch(CAN2OUT); CAN1ID = CAN2ID; CAN1B0 = CAN2B0; CAN1B1 = CAN2B1; CAN1B2 = CAN2B2; CAN1B3 = CAN2B3; CAN1B4 = CAN2B4; CAN1B5 = CAN2B5; CAN1B6 = CAN2B6; CAN1B7 = CAN2B7; CAN1L = CAN2L; CAN1IN = CAN2OUT; } }
/*---------------------------------------------------------------------------- Analog() simulates analog input values given to channel-2 (AD02) *----------------------------------------------------------------------------*/ signal void Analog (float limit) { float volts;
printf ("Analog (%f) entered.\n", limit); while (1) { /* forever */ volts = 0; while (volts <= limit) { AIN2 = volts; /* analog input-2 */ twatch (250000); /* 250000 Cycles Time-Break */ volts += 0.1; /* increase voltage */ } volts = limit; while (volts >= 0.0) { AIN2 = volts; twatch (250000); /* 250000 Cycles Time-Break */ volts -= 0.1; /* decrease voltage */ } } }
signal void Test (float number) { while(1) { printf("Number:%f\n", number); number = getint("Give me a number:"); printf("Number now:%f\n", number); twatch (250000); } }
kill button *
define button "Analog sweep 0 .. 3.3V", "Analog (3.3)" define button "Analog sweep STOP", "signal kill Analog" define button "CAN loopback ON", "CAN_loopback_1_to_2 (); CAN_loopback_2_to_1 ();" define button "CAN loopback OFF", "signal kill CAN_loopback_1_to_2; signal kill CAN_loopback_2_to_1;" define button "Test", "Test(3.1)" define button "Test Done", "signal kill Test"
Thanks for the note on message formatting, and glad to see that this will be addressed in the next MDK release...
/*---------------------------------------------------------------------------- * Name: Dbg_Sim.ini * Purpose: Simulator Debug Initialization File * Note(s): *---------------------------------------------------------------------------- * This file is part of the uVision/ARM development tools. * This software may only be used under the terms of a valid, current, * end user licence from KEIL for a compatible version of KEIL software * development tools. Nothing else gives you the right to use this software. * * This software is supplied "AS IS" without warranties of any kind. * * Copyright (c) 2008-2011 Keil - An ARM Company. All rights reserved. *----------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------- CAN_loopback_1_to_2() simulates loopback connection from CAN1 to CAN2 port *----------------------------------------------------------------------------*/ signal void CAN_loopback_1_to_2 (void) { while (1) { wwatch(CAN1OUT); CAN2ID = CAN1ID; CAN2B0 = CAN1B0; CAN2B1 = CAN1B1; CAN2B2 = CAN1B2; CAN2B3 = CAN1B3; CAN2B4 = CAN1B4; CAN2B5 = CAN1B5; CAN2B6 = CAN1B6; CAN2B7 = CAN1B7; CAN2L = CAN1L; CAN2IN = CAN1OUT; } } /*---------------------------------------------------------------------------- CAN_loopback_2_to_1() simulates loopback connection from CAN2 to CAN1 port *----------------------------------------------------------------------------*/ signal void CAN_loopback_2_to_1 (void) { while (1) { wwatch(CAN2OUT); CAN1ID = CAN2ID; CAN1B0 = CAN2B0; CAN1B1 = CAN2B1; CAN1B2 = CAN2B2; CAN1B3 = CAN2B3; CAN1B4 = CAN2B4; CAN1B5 = CAN2B5; CAN1B6 = CAN2B6; CAN1B7 = CAN2B7; CAN1L = CAN2L; CAN1IN = CAN2OUT; } } /*---------------------------------------------------------------------------- Analog() simulates analog input values given to channel-2 (AD02) *----------------------------------------------------------------------------*/ signal void Analog (float limit) { float volts; printf ("Analog (%f) entered.\n", limit); while (1) { /* forever */ volts = 0; while (volts <= limit) { AIN2 = volts; /* analog input-2 */ twatch (250000); /* 250000 Cycles Time-Break */ volts += 0.1; /* increase voltage */ } volts = limit; while (volts >= 0.0) { AIN2 = volts; twatch (250000); /* 250000 Cycles Time-Break */ volts -= 0.1; /* decrease voltage */ } } } signal void Test (float number) { while(1) { printf("Number:%f\n", number); number = getint("Give me a number:"); printf("Number now:%f\n", number); twatch (250000); } } kill button * define button "Analog sweep 0 .. 3.3V", "Analog (3.3)" define button "Analog sweep STOP", "signal kill Analog" define button "CAN loopback ON", "CAN_loopback_1_to_2 (); CAN_loopback_2_to_1 ();" define button "CAN loopback OFF", "signal kill CAN_loopback_1_to_2; signal kill CAN_loopback_2_to_1;" define button "Test", "Test(3.1)" define button "Test Done", "signal kill Test"