With old compiler V.7.20 the code runs, with the new compiler the processor does not.
What I noticed in the new code generated is the following
0012 C3 CLR C
0013 E500 E MOV A,time_base0015 9406 SUBB A,#06H0017 7480 MOV A,#080H0019 9480 SUBB A,#080H001B 501A JNC ?C0006
replaces
0012 E500 E MOV A,time_base0014 C3 CLR C0015 9406 SUBB A,#06H0017 501A JNC ?C0006There are a few other differences but this occurs in many places, and the new code is 1K longer than the old code.
If you need additional information, let me know.
Thanks,
Victor
Attached is the source code file; the assembler code above goes for line 74.
//============================================================================== // // C Language Source file for the R3 Radio. // // Copyright (C) 2017 by Laird Technologies, Inc. All rights reserved. // // This document and all information contained within are the exclusive, // confidential and proprietary property of Laird Technologies Inc. It is not // to be reproduced, nor is it or any portion of it to be used by or // disclosed to any other individual or legal entity, without the prior, // written approval of Laird Technologies Inc. Furthermore, the information // contained within this document is also to be handled in accordance with // any and all confidentiality agreements between Laird Technologies Inc. and // the receiver or user of this document. // //============================================================================== /************************************************************************** FILE: ATOD.C DATE: 11-24-93 REV. 0 by RAC 03-09-2017 JSD update to work with new microcontroller PURPOSE: Define A/D converter routines. NOTES: The C statement to check for completion of A/D conversion on 80C562 "while (!(ADCON & 0x10));" should always be used as shown. This is the interrupt flag (bit 4) conversion complete. Do not use the busy flag (bit 3) for checking the status of the conversion in process. This would sometimes give bogus A/D results when the this was read immediately after stating the conversion. ****************************************************************************/ #pragma CODE DEBUG SYMBOLS SMALL #include "AT89C51AC3.h" /* special function register declarations */ #include "protos.h" /* Function prototype definitions */ #include "rec_def.h" /* Definitions of constant values */ #include "globals.h" /* Global variables for EZ model. */ #define BLOCK 6 /* this value x 125uS for A/D blocks rssi rise search */ /***************************************************************************/ unsigned char get_ad(unsigned char channel) { ADCON &= 0xEF; /* Clear end-of-conversion flag */ //THIS MAY OR MAY NOT BE NEEDED, CAN TRY WITHOUT LATER ADCON &= 0xF8; /* Clear A/D channel select */ ADCON |= channel; /* select A/D channel */ ADCON |= 0x08; /* start A/D conversion */ while ((ADCON & 0x10) == 0); /* wait for conversion to complete */ return (ADDH); /* Return A/D result */ } /*************************************************************************/ void start_ad(unsigned char channel) /* Start A/D conversion for the channel */ { /* specified. */ ADCON &= 0xE8; /* Clear end-of-conversion flg, clear chan */ ADCON |= channel; /* Set channel */ ADCON |= 0x08; /* Start conversion. */ } /*****************************************************************************/ unsigned char ad_block (unsigned char chan) /* Do A/D conversions for 1mS of */ { /* time on the channel received. */ unsigned char count = 0; /* Return the average A/D value */ unsigned int sum = 0; /* for the 1mS time period. */ reset_timer(0, uS125); time_base = 0; while (time_base < BLOCK) /* Sum A/D conversions for 1mS (125uS x 8) */ { start_ad(chan); while (!(ADCON & 0x10)); /* Wait for conversion complete */ sum += ADDH; count++; } return (unsigned char)(sum/(unsigned int)(count)); } /***************************************************************************/
You need to use Insert -> Code.
I have noticed the code is bigger too. I don't know all the changes, but watch the data types and comparisons. I think one of the changes might have been that default types are int instead of unsigned int? Also in your Target C51 settings there is a checkbox for integer promotion. Compare with the old project settings.
There should really be a Keil document for migrating code because these types of compiler changes can cause havoc.