Electronics > Microcontrollers
PIC18F1320 in a Raman Spectrometer
ataradov:
Well, UART is a peripheral, so it would be different between different MCUs. So, you can't take C code for one MCU and compile it for another MCU without changing device-specific parts.
You've already been pointed at a few MCUs that have higher resolution SDADC. Those may or may not be good enough for your application.
Even if you fond some readily available eval board with 24-bit ADC and a MCU (there are not too many of those, I imagine), all the example code would be in C. And it is not likely that example code would do precisely what you want, so you would have to modify it anyway.
Internal ADCs in the MCUs are not meant for metrological applications.
But also, 24-bits is not about accuracy or resolution, but about dynamic range. If you don't need wide dynamic range, you can use low noise amplifier and use internal ADC just as well.
planc:
--- Quote from: ozcar on February 07, 2023, 05:33:52 am ---
--- Quote from: planc on February 07, 2023, 05:20:17 am ---(oscar, I ran it using AS11.EXE. THRSIM11 simulator can't run them if the labels have duplicates. I'll try using different labels and and ran them again in AS11.EXE)
--- End quote ---
The ancient version of AS11 I have here from the days I used to tinker with HC11 does complain. If something does not complain, then I can only guess that maybe later use of the same symbol replaces the earlier one from that point onward (and you would have to be very careful not to get yourself into trouble with that).
Really that code should be in a subroutine, rather than repeating it every time.
--- End quote ---
Oscar. You are few of the people I know who is familiar with the HC11. So please don't miss the reply to the above (I'll repost this here and delete the reply an hour ago)
I run As11.exe now. It doesn't complain and correctly jumps to the label just above it. That's why it could still output the txt "Hello". I also changed all labels to unique ones. And the same. I know unique labels are important because I was lost in the loop late last year until I discovered the duplicate labels can miss things up. As11.exe doesn't report any error.
Anyway. I think you missed the reply (dated January 28) to your query about Trace. After reading about your Trace thing. I connected jumper XIRQ and PA3, and saw Trace worked for the first time.
Again. I wrote and asked in that January 28 message (pls answer it, thanks).
"A while ago. I used the trace function in Buffalo for the first time. It worked so nice. Didn't know the unit could really do that. But I noticed that whenever it passed through an interrupt enable (for example the CLI which enabled the Real Time Interrupt) . The trace got stuck on the next instruction"
1. Why did it get stuck after passing through instruction that enabled the interrupt? How do you proceed after it got stuck?
ozcar:
--- Quote from: planc on February 07, 2023, 08:13:35 am ---
Oscar. You are few of the people I know who is familiar with the HC11. So please don't miss the reply to the above (I'll repost this here and delete the reply an hour ago)
I run As11.exe now. It doesn't complain and correctly jumps to the label just above it. That's why it could still output the txt "Hello". I also changed all labels to unique ones. And the same. I know unique labels are important because I was lost in the loop late last year until I discovered the duplicate labels can miss things up. As11.exe doesn't report any error.
--- End quote ---
Show us the listing for that assembly when you use the same name several times.
The AS11.EXE that I have throws out this (and refuses to give a normal listing):
--- Code: ---27: Symbol Redefined
33: Symbol Redefined
39: Symbol Redefined
45: Symbol Redefined
51: Symbol Redefined
--- End code ---
If I change the symbols to be unique, it produces this listing:
--- Code: ---0001 1000 REGBASE EQU $1000
0002 1028 SPCR EQU $1028
0003 102b BAUD EQU $102B
0004 102c SCCR1 EQU $102C
0005 102d SCCR2 EQU $102D
0006 102e SCSR EQU $102E
0007 102f SCDR EQU $102F
0008
0009 0100 ORG $0100
0010
0011 0100 86 30 START LDAA #%00110000 ; 00110000 = 9600 BAUD
0012 0102 b7 10 2b STAA BAUD ; 00110011 = 1200 BAUD
0013 0105 7f 10 2c CLR SCCR1
0014 0108 86 0c LDAA #$0C
0015 010a b7 10 2d STAA SCCR2 ;RECEIVER & TRANS. ENABLED
0016 010d 7f 10 28 clr SPCR
0017
0018 LOOP
0019
0020 0110 86 48 ldaa #72 ; send "H" to serial
0021 0112 f6 10 2e read_again ldab $102e ;
0022 0115 c5 80 bitb #$80
0023 0117 27 f9 beq read_again
0024 0119 b7 10 2f staa SCDR ;
0025
0026 011c 86 65 ldaa #101 ; send "e" to serial
0027 011e f6 10 2e read_again1 ldab $102e ;
0028 0121 c5 80 bitb #$80
0029 0123 27 f9 beq read_again1
0030 0125 b7 10 2f staa SCDR ;
0031
0032 0128 86 6c ldaa #108 ; send "l" to serial
0033 012a f6 10 2e read_again2 ldab $102e ;
0034 012d c5 80 bitb #$80
0035 012f 27 f9 beq read_again2
0036 0131 b7 10 2f staa SCDR ;
0037
0038 0134 86 6c ldaa #108 ; send "l" to serial
0039 0136 f6 10 2e read_again3 ldab $102e ;
0040 0139 c5 80 bitb #$80
0041 013b 27 f9 beq read_again3
0042 013d b7 10 2f staa SCDR ;
0043
0044 0140 86 6f ldaa #111 ; send "o" to serial
0045 0142 f6 10 2e read_again4 ldab $102e ;
0046 0145 c5 80 bitb #$80
0047 0147 27 f9 beq read_again4
0048 0149 b7 10 2f staa SCDR ;
0049
0050 014c 86 20 ldaa #32 ; send "space" to serial
0051 014e f6 10 2e read_again5 ldab $102e ;
0052 0151 c5 80 bitb #$80
0053 0153 27 f9 beq read_again5
0054 0155 b7 10 2f staa SCDR ;
0055
0056 0158 20 b6 BRA LOOP
--- End code ---
--- Quote from: planc on February 07, 2023, 08:13:35 am ---
Anyway. I think you missed the reply (dated January 28) to your query about Trace. After reading about your Trace thing. I connected jumper XIRQ and PA3, and saw Trace worked for the first time.
...
Again. I wrote and asked in that January 28 message (pls answer it, thanks).
"A while ago. I used the trace function in Buffalo for the first time. It worked so nice. Didn't know the unit could really do that. But I noticed that whenever it passed through an interrupt enable (for example the CLI which enabled the Real Time Interrupt) . The trace got stuck on the next instruction"
1. Why did it get stuck after passing through instruction that enabled the interrupt? How do you proceed after it got stuck?
--- End quote ---
I used Buffalo to "debug" HC11 code, but I don't recall ever using the trace facility - I was used to other monitor programs for 6800 and 6809 that did not have anything like that. Looking now at how the trace works I'm pretty sure a badly behaved user program could cause trouble, as the ram locations used by Buffalo itself are not protected in any way. I'm not saying that is what happened, but it is a possibility.
If things went wrong when you enabled IRQ, are you sure the interrupt handling code was set up correctly? Show the listing of the code you were trying to trace. If you were trying to trace execution in Buffalo itself, well, I'm not sure that is supported - it makes my head hurt to think what might happen.
planc:
If the filename is hw.txt with the multiple identical read_again labels. I used the following commands to compile in ms dos
as11 hw.txt
or
as11 hw.txt -1 >hw.1st
The hw.1st is empty when there is no error, and it successfully compiled to hw.s19 which I can run in the HC11.
How do you show the listing with the address 0001 1000.. 0009 0100?? I'll try to reproduce that listing because I haven't seen it before (address listed).
About the interrupt and trace. It's the EEG firmware itself. I think when it encountered the real time interrupt enabled, it waits for the interrupt in the background and so the trace got stuck. It only happens whenever it passed by CLI. The firmware works perfectly because it can send the 2 channels into one serial stream and then separately splits or outputs them at the EEG pc software.
ozcar:
--- Quote from: planc on February 07, 2023, 10:54:14 am ---If the filename is hw.txt with the multiple identical read_again labels. I used the following commands to compile in ms dos
as11 hw.txt
or
as11 hw.txt -1 >hw.1st
The hw.1st is empty when there is no error, and it successfully compiled to hw.s19 which I can run in the HC11.
How do you show the listing with the address 0001 1000.. 0009 0100?? I'll try to reproduce that listing because I haven't seen it before (address listed).
--- End quote ---
I was using -L option on the command, so similar to your command, but in upper case. I just tried it now with -l instead, and that works too. If I don't use either, I just get an empty file. Maybe there is some way to set up defaults for the options, but it is so long since I was using this that I have forgotten.
But it seems the AS11 you have may be different.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version