Dear Roger,
For comparison I used the latest version of the BDM programmer to download compiled versions of the program below to the following chips:
SE8, trim value $B7.0
QG8, trim value $B3.1
The program can do 2 things - Produce a square wave at a cycle-counted speed (400kHz => 8MHz bus clock) or send a single character out the serial port. Uncomment the testClockPeriod() line for the square wave. This is similar to the program that I used to test the clock trimming on all the supported chips.
For both chips the square wave was at 399kHz as expected for a 8MHz bus clock.
I also measured the baud rate in each case to be 9600 baud.
The program sets the BDIV to 0 as I believe is required for 8MHz bus speed on these chips.
I'm at a loss why your results are different for these two chips. They have the same type clock system and SCIs and the programmer-calculated trim values are similar as expected. Why should the execution results differ?
Are you using the latest version programmer available as indicated above (This should be irrelevant since its the clock trim value that is the sticking point) ?
Does the programmer auto-detect the chip type correctly?
Could you try these two programs on your chips?
bye
#include <hidef.h> /* for EnableInterrupts macro */#include "derivative.h" /* include peripheral declarations */typedef unsigned char U8;#define PORTD PTCD // Test Port Data register#define PORTDD PTCDD // Test Port Data Direction register#define LED1 (1<<1) // Test pins#define LED2 (1<<0)// Clock Trim values in Flash - dummy values overwritten by flash programmerstatic const volatile U8 NV_FTRIM_INIT @0x0000FFAE = 0xFF; // LSBstatic const volatile U8 NV_ICSTRM_INIT @0x0000FFAF = 0xFF; // MSBvoid initClock( void ) { if (NV_ICSTRM_INIT != 0xFF) { // Only trim & update clock if Trim values have been programmed to Flash. // Enabling x1 clock divider on untrimmed device may be out of bus clock spec. ICSSC = NV_FTRIM_INIT; // Trim the internal clock ICSTRM = NV_ICSTRM_INIT; // Set 8/16 MHz bus clock assuming 31.25 MHz trim ICSC2 = 0; // BDIV=0,RANGE=0,HGO=0,LP=0,EREFS=0,ERCLKEN=0,EREFSTEN=0 ICSC1 = ICSC1_IREFSTEN_MASK; // CLKS=0,RDIV=0,IREFS=1,IRCLKEN=0,IREFSTEN=0 }}void testClockPeriod(void) { PORTDD = LED1|LED2; // Set as outputs asm { lda #LED1 Loop: // 10 bus cycles low sta PORTD // 3 eor #LED1|LED2; // 2 nop // 1 nop // 1 bra Loop // 3 // 10 => 20 cy for 2 interations // 20 bus cycles @ 4MHz bus freq. => 200kHz, 5.00 us // 20 bus cycles @ 5MHz bus freq. => 250kHz, 4.00 us // 20 bus cycles @ 8MHz bus freq. => 400kHz, 2.50 us // 20 bus cycles @ 10MHz bus freq. => 500kHz, 2.00 us // 20 bus cycles @ 16MHz bus freq. => 800kHz, 1.25 us // 20 bus cycles @ 20MHz bus freq. => 1MHz, 1.00 us }}#define FBUS (8000000UL)#define FBAUD (9600)void initSCI(void) { SCIBD = FBUS/16/FBAUD; SCIC2 = SCIC2_TE_MASK;}void sendChar(char ch) { for(;;) { SCID = ch; while (!SCIS1_TDRE) { } }}void main(void) { SOPT1 = SOPT1_STOPE_MASK|SOPT1_BKGDPE_MASK; // Watchdog off, STOP enabled, BKGD pin enabled, initClock();// testClockPeriod(); initSCI(); sendChar('A');}