Hi,
I'm trying to use some old MC68705R3S microcontrollers for a project for the local Amateur Radio Club, but am having problems getting any code to work properly. The following code will only work if I replace the call to DELAY22 with WAIT1MS and even then the actual delay time is different on different chips. Any help will be greatly appreciated.
Best Regards
Trev Jackson
0001 0000 .msfirst
0002 0000
0003 0000 porta .equ $0000 ; port A data register
0004 0000 portb .equ $0001 ; port B data register
0005 0000 portc .equ $0002 ; port C data register
0006 0000 portd .equ $0003 ; port D data register
0007 0000 ddra .equ $0004 ; port A data direction register
0008 0000 ddrb .equ $0005 ; port B data direction register
0009 0000 ddrc .equ $0006 ; port C data direction register
0010 0000
0011 0000 ;********User RAM (128 Bytes) starts at address $010*********
0012 0000
0013 0000 temp1 .equ $010
0014 0000
0015 0000 ;***************************************************************
0016 0100 .org $100 ; start of 3640 BYTES user EPROM area
0017 0100 ;***************************************************************
0018 0100
0019 0100 ;***************************************************************
0020 0100 ; short delays
0021 0100
0022 0100 9D DELAY22: nop ;22uS
0023 0101 9D DELAY20: nop ;20uS
0024 0102 9D DELAY18: nop ;18uS
0025 0103 9D DELAY16: nop ;16uS
0026 0104 81 DELAY14: rts ;
0027 0105
0028 0105 ;***************************************************************
0029 0105 ; Wait1ms-- Waits here for 1ms
0030 0105
0031 0105 WAIT1MS:
0032 0105 BF 10 stx temp1 ; 6uS
0033 0107 BE 78 ldx 120 ; 2uS
0034 0109 5A DB3B: decx ; 4uS
0035 010A 26 FD bne DB3B ; 4uS
0036 010C 9D nop ; 2us
0037 010D 9D nop ; 2us
0038 010E 9D nop ; 2us
0039 010F 9D nop ; 2us
0040 0110 BE 10 ldx temp1 ; 5uS
0041 0112 BE 10 ldx temp1 ; 5uS
0042 0114 81 rts ; 6uS (1000uS)
0043 0115
0044 0115 ;***************************************************************
0045 0115 ; main code
0046 0115
0047 0115
0048 0115 START:
0049 0115 A6 FF lda #$FF ;port A as outputs
0050 0117 B7 04 sta ddra
0051 0119 B7 05 sta ddrb ;port B as outputs
0052 011B B7 06 sta ddrc ;port C as outputs
0053 011D 3F 00 clr porta ;data=$00 RW=0 RS=0 E=0
0054 011F 3F 01 clr portb
0055 0121 3F 02 clr portc
0056 0123 LED1
0057 0123 10 01 bset 0,portb
0058 0125 CD 01 00 jsr DELAY22 ;22uS
0059 0128 11 01 bclr 0,portb
0060 012A CD 01 00 jsr DELAY22 ;22uS
0061 012D CC 01 23 jmp LED1
0062 0130
0063 0130 ;***********************************************************
0064 0130 ; Interrupt Service Routines -- (Interrupts not currently used)
0065 0130
0066 0130 CC 01 15 TOVFLW: jmp START
0067 0133 CC 01 15 IRQ: jmp START
0068 0136 CC 01 15 SWI: jmp START
0069 0139
0070 0139 ;***********************************************************
0071 0FF8 .org $FF8 ; set reset vectors
0072 0FF8
0073 0FF8 01 30 .dw TOVFLW ; $FF8-9
0074 0FFA 01 33 .dw IRQ ; $FFA-B
0075 0FFC 01 36 .dw SWI ; $FFC-D
0076 0FFE 01 15 .dw START ; $FFE-F
0077 1000
0078 0F38 .org $F38
0079 0F38
0080 0F38 60 .db $60
0081 0F39
0082 0F39 .end
tasm: Number of errors = 0
Solved! Go to Solution.
Hi All,
Thanks everyone for your help
It looks like the problem with the different versions of my code not working is nothing to do with the actual code, but that some of the EPROMs I've been using don't appear to be compatible with the 68705 programming board.
The first EPROMs I used were AMD AM27C64-205DC EPROMs (I grounded A12 as it isn't used) - the reason I used 27C64 EPROMs rather than the 2532 EPROMs that are supposed to be used is because I only had one 2532 and my modern universal device programmer wouldn't program it.
Most of the later versions of the software (the ones that didn't work) used Fairchild NMC27C64Q EPROMs and despite my universal programmer being happy to program them with the settings left the same (I did check the programming voltage, pinout etc) and they all verified OK.
However for some reason the 68705 programmer appears to be incompatible with those EPROMs, I've just sorted out some more AMD EPROMs and used one of them to program a 68705 with a version of software that wasn't working and it runs OK now.
Thanks again and Best Regards
Trev Jackson
Hi Trev,
Welcome to the forum.
The first questions:
What type of oscillator are you using and what kind of timing variations are you experiencing? The R3 can use almost anything from a crystal to a pullup resistor or jumper. The resistor approach can have a 25% variation from chip to chip, and the jumper approach (between XTAL and EXTAL) can have a 50% variation. From your MOR register and comments, it looks like you are configured for a 1 Mhz crystal.
Now in your WAIT1MS routine, notice the line:
ldx 120 ; 2uS
I assume you want to load X with 120, but you are instead loading X with the contents of location 0x78. Since you never initialize ram, that value will likely be different for each MCU. The instruction should be:
ldx #120 ; 2uS
As far as DELAY22 not working, what kind of symptoms are you getting?
Hi,
Thanks for pointing out my mistake in loading a memory location, rather than an immediate value - that explains the variation in the time periods - which were x0.25 x0.5 x0.75 x1 and x2 of the original chip I tried - I feel confident that fixing the code error will fix that.
As I was having problems with what appeared to be the crystal stopping (checking with the oscilloscope was showing no oscillation with one version of software and 4MHz with another), I tried an external clock - the external clock is 4MHz giving a 1MHz internal clock cycle.
When I try to run the code with the 22uS delay I don't get any output at all from the chip and putting the oscilloscope on the output pin (Port B, bit 0) just gives 5V - externally I have an LED connected through a 510 ohm resistor to 5V.
Thanks again for your help.
Best Regards
Trev
Trev,
Unless and even if you are using a low capacitance probe, the probe capacitance can sometimes kill the oscillator and oftentimes alter the frequency. In either case, the sudden application of the probe capacitance can stop the clock resulting in unknown errors. If you must probe the clock, make sure the probe is connected on the oscillator output terminal and not the feedback terminal and connected prior to power on.
Good Luck,
Peter House
Hi Peter,
I checked the crystal with both versions of software (using the same mcu) and with one version is oscillated, with the other it didn't. Just in case something weird was going on inside the mpu I thought I would make sure that it had a nice strong clock, by setting up an external oscillater, which is then bufferred through a 4001 NOR gate. The EXTAL clock input now always has a strong clock signal and the XTAL input is connected to GND as per the MC68705R3 Technical Summary data sheet.
Best Regards
Trev
Trev,
For anything serious I have learned to use an external oscillator especially if the engineering time is short and there is no temperature range testing or other environmental testing. The external oscillators already have this engineering inside and consequently cost a little more.
Peter
Hi All,
Thanks everyone for your help
It looks like the problem with the different versions of my code not working is nothing to do with the actual code, but that some of the EPROMs I've been using don't appear to be compatible with the 68705 programming board.
The first EPROMs I used were AMD AM27C64-205DC EPROMs (I grounded A12 as it isn't used) - the reason I used 27C64 EPROMs rather than the 2532 EPROMs that are supposed to be used is because I only had one 2532 and my modern universal device programmer wouldn't program it.
Most of the later versions of the software (the ones that didn't work) used Fairchild NMC27C64Q EPROMs and despite my universal programmer being happy to program them with the settings left the same (I did check the programming voltage, pinout etc) and they all verified OK.
However for some reason the 68705 programmer appears to be incompatible with those EPROMs, I've just sorted out some more AMD EPROMs and used one of them to program a 68705 with a version of software that wasn't working and it runs OK now.
Thanks again and Best Regards
Trev Jackson
Trev,
Glad you got it working and thanks for letting us know!
Peter