Where can I find DEBUG instructions?

The Atom Pro BASIC manual directs people to an online HELP section that details how to use the DEBUG feature. I can’t find anything like this at the Basic Micro site. Can anyone help me out with this? I left an email with BM Support, but these forums seem to be more active and informed about Atom Pro items, so I thought I’d try the question here as well.

I hope you’re having as much fun with your project(s) as I am.
kenjj

I don’t think there is much documentation on the debug feature other than the DEBUG and DEBUGIN commands.

You enter the debugger mode using the Debug button (or the Debug item in the tools menu). The Serial port you use to program the Atom Pro is used to communicate during the debug session. You then can set break points, step through your code, use the run command to actually get things running, etc.

Do you have any specific questions on it?

Kurt

Yes. I have used Basic Micro’s other compilers, so DEBUG is not a complete mystery, although I rarely use it to troubleshoot.

I am using Atom Pro BASIC 8.017 on a PC with XP Home, 3.06GHz Pentup4, 1Gig RAM. I had BM program some H83687s, their Atom Pro Plus chip. This is installed on a development board of my own creation. Yes, I’ve observed all the amenities of good digital design, and have progressed to running both hardware serial ports successfully.

I used the DEBUG button in Atom Pro 8.017 to compile with, turned on SFR monitoring, and clicked on AutoUpdate. All well and good, but the green bar won’t advance beyond the first “sethserial” initialization in my code when I use “single step”, or any other debug stepping method.

I arrived at this point because the ADIN command doesn’t work in any way, shape or form for me. BM’s support told me to program the ADC registers directly, and gave me general directions as to how to do that. Which I’ve done, but it’s problematic. The ADDRD register comes back with zero, whether I’m reading AN3 or AN7. And it only responds when I do four-channels conversions, not for singles. So, I am forced to use DEBUG to monitor registers, but have arrived at this impasse. I would REALLY like to find detailed instructions for using DEBUG, in case I am doing something simple minded, yuh know?

That’s sorta long winded, but I visit forum threads where everybody spins their wheels while they painfully extract details out of the OP over several posts, and I’d like to get it all out here and now.
And the code is:

[code]x VAR WORD
y VAR BYTE
adcsr_val VAR BYTE
fp_VoltsA VAR FLOAT
fp_VoltsB VAR FLOAT
fp_VoltsC VAR FLOAT
fp_VoltsD VAR FLOAT
ADC_Val VAR FLOAT
ADC_Val = 0.00488 ; 4.88mV per ADC increment
ENABLEHSERIAL
sethserial h57600,h8databits,hnoparity,h1stopbits
; ENABLEHSERIAL2
; sethserial2 h57600,h8databits,hnoparity,h1stopbits

MAIN
FOR y = 0 to 255
FOR x = 1 to 65535

ADCSR = %01111011 ; Start scanning conversion, AN0 - AN3, 70 clock states
ADCSR = %01011011

adcsr_val = ADCSR
fp_VoltsA = TOFLOAT ADDRA
fp_VoltsB = TOFLOAT ADDRB
fp_VoltsC = TOFLOAT ADDRC
fp_VoltsD = TOFLOAT ADDRD

fp_VoltsA = ((fp_VoltsA/64) * ADC_Val)
fp_VoltsB = ((fp_VoltsB/64) * ADC_Val)
fp_VoltsC = ((fp_VoltsC/64) * ADC_Val)
fp_VoltsD = ((fp_VoltsD/64) * ADC_Val)

HSEROUT "1- adcsr: ", IBIN adcsr_val\8, 13]
HSEROUT "1-VoltsA ", REAL1 fp_VoltsA\2, ", " ,DEC x, 13]
HSEROUT "1-VoltsB ", REAL1 fp_VoltsB\2, ", " ,DEC x, 13]
HSEROUT "1-VoltsC ", REAL1 fp_VoltsC\2, ", " ,DEC x, 13]
HSEROUT "1-VoltsD ", REAL1 fp_VoltsD\2, ", " ,DEC x, 13, 13]
; HSEROUT “1-”, DEC ADDRD, 13]

PAUSE 1000
NEXT ; x
NEXT ; y

END ; just in case[/code]

Any help is appreciated. Especially guidance on how to do ADC reading(s).
kenjj

Sounds great. I have been following your progress on the BM site.

I am not an expert on their debug section. What I have found is that it works Ok for simple stuff, but breaks down on complicated things. One such example is if your program uses interrupts, it can make it very difficult to do things like step… Also I have at times had problems with the debug window not updating (or showing) variable values.

So I can not give you very much advice. However if it were me, I would try to convert from HSERIAL to their bit bang version (serout) as this would not involve any interrupts and see if you can go a little farther…

Kurt

Yeah, that’s sort of a “Diary of a Mad Developer”. I just finished posting another blather session before jumping straight over to this.

The idea of DEBUG’s tripping up for that reason had occured to me. Your’s sounds like a reasonable solution. Any thoughts on the ADIN problem? Can anyone suggest better register usage?
Thanks for the input.
kenjj

Not sure about the problems with ADIN. However the first thing I looked at was the location of the control registers. I had dificulties making the hardware I2C work on my PRO. That is when I figured out that the later pros use the 3694 and the Pro software is configured for the 3664 and some of the hardware registers that work with I2C changed locations. So far this does not look like the issue.

I do think there are problems with your setup for ADCSR. A quick look at thee values looks like, you are turning on ADIE which looks like you are supposed to get an interrupt at Analog conversion complete (ADINT), but you have not defined any handles. It also looks like you set for SCAN mode which is fine, but it also looks like you first turn on conversion and the next line turns it back off again(ADST), which may also be the problem. Again I have not played with this stuff, but I would probably not turn on the interrupt, probably turn on scan mode and then guessing I would probably have my code loop until the ADF bit is set, which I think implies that a conversion is complete…

That is all for now as it is time to go.
Kurt

Fair enough. I had the 3687 data sheet in front of me when I started out with this. It didn’t seem all that complicated. I have dithered the bits so many ways so many times I probably dropped the thread a long time ago. I tried inserting a single channel scan session in between the start and stop settings, among other things. I tried shortening the clock count to 70 clock states, from 134, in the hopes the shorter conversions would see usable results in ADDRD.
Then I started experimenting with ADCSR bits that probably had nothing to do with the situation, I thought, observing what, if any, effect these had. At present, I get four readings back with each scan: ADDRA to ADDRC are between 4 and 5 Volts, ADDRD is hard zero. Any other settings produce nothing on the screen. A heart beat LED would be helpful at this point.

I’ll try a bitbang port and add an LED and see where I get from here. Thanks for the suggestions, Kurte. Anyone else have any input?
kenjj

Sorry, it is just me again…

I was playing around some on my Pro28 to see if I could get anything to work. Start off with something simple, like scanning AN4-7 (high pins on the pro). I hooked up one Sharp IR sensor on P16, which appears to be getting some results.

This code looked like:

[code]y VAR BYTE

MAIN
ADCSR = %00111111 ; Start, do Scan AN4-AN7, 134 clock states
;ADCSR = %00001100 ; Setup to do a single scan at a time of only AN4
while ADCSR.bit7 = 0
pause 1
wend

FOR y = 0 to 255 

	serout s_out, i9600,  [hex ADDRA, " ", hex ADDRB, " ", hex ADDRC, " ", hex ADDRD, 13] 
	PAUSE 1000 
NEXT  ; y 

ADCSR.bit5 = 0	; Stop doing AtoD

END ; just in case[/code]

I will now try to just do AN4 in single mode…

I found playing around and looking at the pinouts for the Pro28 that P16-P19 have the second set of analog pins, but sort of in what you would think is reversed. That is P7 is on P16 and AN4 on P19. Here is a program that shows some outputs…

[code]y VAR BYTE

MAIN
;ADCSR = %00111111 ; Start, do Scan AN4-AN7, 70 clock states
; ADCSR = %00001100 ; Setup to do a single scan at a time of only AN4

FOR y = 4 to 7 
	ADCSR = %00101000 | y	; Setup to do a single scan at a time of only AN4-AB7
	
	repeat
		pause 1
	until (ADCSR.bit7 <> 0) 	; wait for the scan to complete
	
	serout s_out, i9600,  [hex ADDRA, " ", hex ADDRB, " ", hex ADDRC, " ", hex ADDRD, 13] 
	PAUSE 1000 
NEXT  ; y 

goto main

END ; just in case[/code]

Let me know if these programs do anything on your beast!

Kurt

Here is the list of I/O from the wikia…

[code]Pro-28 H8 / 3664F
P16 P11 PB7 / AN7
P17 P12 PB6 / AN6
P18 P16 / IRQ2 PB5 / AN5
P19 P17 / IRQ3 PB4 / AN4 [/code]

Thanks, Kurte, I’ll try the code tonight.
We have a problem here: there is a difference in the pinouts, and probably other things, between the 3664 you mention and the 3687 I have. The Atom Pro manual has several holes in it when it talks about features and pins. It has descriptions about the 24 and 28 pin modules, but gets sketchy about the “Pro Plus”, which is what I have.

F’rinstance, I don’t know which pin is S_OUT/S_IN is on the 3687. I tried using the TXD pin for SEROUT last night, and nothing comes out. That is, I used:
SEROUT P22, I57600, [data blah]
because P22 is the port pin for TXD, the transmit pin of the first USART. I have nothing wired to S_OUT yet. Charts exist in the manual for the 24 and 28 pin module; BM usually ends these discussions with “data forthcoming for the Plus”. There’s no module for the Plus yet, so I am largely exploring virgin territory.

Which is what makes this so much fun!

The Basic does most of the grunt work. I’m just attaching accessories on to the their framework. Eventually you guys, Nathan (AcidTech) and BM’s Support will give me enough data to put all this together.

Thanks for the further input, everyone.
kenjj

I thought I remember seeing some pin assignements for the Atom Pro 40 awhile ago by AcidTech. I did some searching on this forum and found:

AtomPro40+ to H8-3687 pinout P0(P50/WKP0)<->(PB0/AN0) P1(P51/WKP1)<->(PB1/AN1) P2(P52/WKP2)<->(PB2/AN2) P3(P53/WKP3)<->(PB3/AN3) P4(P54/WKP4) P5(P55/WKP5/ADTRG) P6(P56/SDA) P7(P57/SCL) P8(P60/FTIOA0) P9(P61/FTIOB0)<->(P74/TMRIV) P10(P62/FTIOC0) P11(P63/FTIOD0) P12(P64/FTIOA1) P13(P65/FTIOB1)<->(P70/SCK3_2) P14(P66/FTIOC1)<->(P71/RXD_2) P15(P67/FTIOD1)<->(P72/TXD_2) P16(P30) P17(P31) P18(P32) P19(P33) P20(P34) P21(P35) P22(P36) P23(P37) P24(P10/TMOW) P25(P11/PWM) P26(P12) P27(P23) P28/AX0(P14/IRQ0)<->(PB7/AN7) P29/AX1(P15/IRQ1/TMIB1)<->(PB6/AN6) P30/AX2(P16/IRQ2)<->(PB5/AN5) P31/AX3(P17/IRQ3/TRGV)<->(PB4/AN4)

This is in the thread:lynxmotion.net/viewtopic.php?t=2597
Unfortionatly it does not show which IO pins are assigned to S_IN and S_OUT. I know that both S_IN and S_OUT us P14 on the Pro28 through a diode circuit. This coorespondes to IRQ0 as well. I thought I remember Acidtech saying that on the Pro40 they were going to split this up to two different IO pins, but I have not found the post yet.

That is all for now.
Kurt

GOLD!! Absolute, 2400 Karat, swingin’ GOLD!!

BTW, Nathan doesn’t list the S_xxx pinouts in the chart, but reveals quickly they are the RXD_1 (S_IN) and TXD_1 (S_OUT) pins. Unlike the 24/28 pin modules, the Plus uses both pins, rather than a single pin with a diode to seperate the two signals from the MAX2323 chip. So, basically, since I’m already wired to those, I should only have to do
SEROUT S_OUT, etc
and print outs should work.

I guess I can email Nathan and tell him to ignore my earlier request for these. IF things work as I think they should. Perhaps I can dope out how to make ADIN work from this info?!

It’s all coming together! Thanks, Kurt.
kenjj

Like a CHARM they work! I had to set the start bit in the line where you read just the one ADC, AN4, and then that worked. I particularly thought ANDing the y value to the ADCSR register was trick. I don’t know how I missed the bit 7 as the Conversion-Ends flag.

So, I now have gotten past problems using SERxxx commands, ADC use and obtained the pinouts for this beast in ONE DAY! :smiley:

I just want to check one thing, then I’m off to update my Emperor’s New Module Diary.
kenjj

FYI - the newer Pro-28s appear to use the 3694s which are reasonably compatible, however be careful with some of the IO registers as some of them have changed. In particular I know the underlying I2C support has changed between the two chips…

As for these IO pins, this is also in the AtomPro manual, but I am not sure if this is accurate. Looking at their generated code, it appears to me like they are internally processing it as:
P16 -> AN7
P17 -> AN6
P18 -> AN4
P19 -> AN5
Now it could be I am reading their generated code improperly or their code is not corrent (8.0.1.7) or they switched up some IO pins and they may need to update their documents…

Kurt

Hi Kurt, I thought that out of order thing was fixed in 8.0.1.7. Not sure, but I will find out and post here. :wink:

Kurte is correct on the I2C hardware(this does not apply to the i2cin and i2cout commands because those are bitbanged). Renesas changed the I2C hardware on the 3694 to an enhanced version which blows out all the old I2C registers so make sure if you are using the 3694 version of the AtomPro you use the correct register locations. I’ve added them to my current test build so the next release will have the 3694 register names defined as well as the older 3664 registers. I only noticerd this myself because I needed to use the i2c hardware a couple weeks ago.

As for the order of which AN pins are which A/D pins:

Pro24:
P0 = AN0
P1 = AN1
P2 = AN2
P3 = AN3

Pro28:
P0 = AN0
P1 = AN1
P2 = AN2
P3 = AN3
P16 = AN7
P17 = AN6
P18 = AN4
P19 = AN5

If you have a 3687 processor I need to know when you got it so I can try to figure out which pinouts it was programmed as. There are two. The AtomPro+ 40 pinout and the AtomPro SMT SE. Both use the 2 wire S_IN/S_OUT but the AtomPro+ 40 expects a lot of pins to be wired to the same locations while the SE every pin has a seperate P#.

Also the reason the last 4 A/D pins on the Pro28 are out of order is because of routing. There was no way to make them line up in order. This shouldn’t be a problem for most since most will use the ADIN command which just uses the P# to designate the A/D pin to use. If you are going to access the ADin hardware directly(eg for scanning mode) you will have to keep the order in mind.

Thanks Nathan. It is not just that they added new register names, they also moved some. For example: ICMR on the 3664 is at address 0xFFC7 and on the 3694 it is at 0xF74A.

This bit me as nothing worked and finally I used the tools to dump the generated binary and found I was not updating the right location…

FYI - Let me know if you need/want someone to test out some new versions of the IDE or some new hardware…

So should we update the WIKI for these two pins. I would assume that it should read that:
P18 P16/IRQ2 PB4/AN4
P19 P17/IRQ3 PB5/AN5

Do you want to do this and or someone like Beth or would you like some of us end users to attempt to make updates?

Also should we add an entry in the 8.0.1.7 bug list about this so that maybe the documention should be updated in the next release?

Thanks
Kurt

Just so everyone knows this is an ADIN command issue. I’ll fix the order in the next release. The ADIN command has a table defined for each module that tells it what pin numbers(eg P16,p17 etc) has which AN# pin on it. That table may be wrong. In which case I’ll fix it.

I use the adin command for battery logging.
atom pro 24m, 8.0.1.7 IDE.

This is a snippet of the actual code.
analog gets the 10bits of the adin command.
then it gets converted to float (from integer)
finally it gets scaled to volts for printing.
I use TeraTerm so that I can log data to a FILE/LOG file.
This program has a pause of 3600000, yep, once an hour.

It took me 2 days from never seeing a stamp to get this done.
I love Atom’s!

— cut here —
index var word
analog var word ’ adin #port, returns 10 bits.
volts var float
convert var float
convert = 1024.0 / 5.0 ’ 204.8 bits per volt
cr con $0D
comma con $2C

input p0 ’ the analog ports
input p1
input p2
input p3

’ (Second) Hardware Serial UART #1; no flow controls.
’ pin 14 = RXD
’ pin 15 = TXD
enablehserial
sethserial h9600, h8databits, hnoparity, h1stopbits

index = 0 ’ init the counter

’ This runs forever…
Main:
index = index +1 ’ next group of 16 chunks of “data”
hserout [dec index] ’ send the index#
adin p0, analog ’ read the CH0 analog port into “analog”
gosub raw2volts
hserout [comma,real volts\4] ’ print “,volts.4places”
goto Main

raw2volts:
rawdata = tofloat analog ’ convert integer(analog) to float(rawdata).
volts = rawdata / convert ’ scale raw(rawdata) to float(volts).
return

end
— cut here —

Paul