BasicMicro - Forums

www.basicmicro.com
It is currently Sun May 20, 2012 10:58 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Demo Code for Atom28(D) module, Atom Lab Board
PostPosted: Fri Jun 26, 2009 7:01 pm 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
This is a copy of the Demo code for the Atom28 module taken from the Atom lab Board's data sheet. Notice the "(D)" in this thread's title. This is a reminder you must specify the 'D' part in the IDE's part selector, i.e., BasicATOM-28D, IF you have the 'D' part. If you purchased the module a year or more ago, it's safe to say it isn't a 'D' part. If you select the wrong part, weird things will happen. I know. I selected the wrong part. It did weirrrd things. :(
Another gotcha is when you copy and paste this from the download PDF page to the programming area of the IDE. Look at the quotes (") around "Hello World". They aren't right. Mine came out as blocks. If you don't change these back to ", then the build or programming fails.

It's well commented, so study the comments some. They will guide wiring later if you don't have the Lab Board itself. You'll notice there are small differences between this and the copy in the data sheet in the LCDWRITE and SEROUT routines. For some reason the original writer created the variable "cnt", then increments it by one every pass through the "main" routine, but never uses it?! So I made it part of the SEROUT.

Code:
;Atom28(D): P16:P19 are on AX0:AX3 of the Lab Board
;Wiring
;P19/AX3 to POT
;P16/AX0 to LED1
;P15 to LED2
;P14 to LED3
;P13 to LED4
;P12 to Button1
;P11 to Button2
;P10 to Buzzer/Speaker
;P9 to Button3
;P8 to Button4

;Setup LCD
lcdinit p0p1p2,outb
lcdwrite p0p1p2,outb,[CLEARLCD,HOMELCD,SCR,TWOLINE,"Hello World"]

;Set pins to known state
low AX0
low p15
low p14
low p13
high p3

;Setup 32 bit variables
temp var long
cnt var long
cnt=0

;Start program main loop
main
;Read analog pin and display value to LCD
cnt=cnt+1
adin AX3,temp
lcdwrite p0p1p2,outb,[SCRRAM+40, "temp: ", dec4 temp4]  ; Jump to LCD second line, print temp

;Send analog reading to terminal window set to 9600 baud
serout S_OUT,i9600,["temp: ", dec temp4, " cnt: ", dec cnt, 13]

;Copy state of button switches to LEDs, on/off
out28=in12 ;P28 is AX0
out15=in11
out14=in9
out13=in8

; If button 4 is pressed make sound with buzzer
out3=in8
if(in8)then  ; Nice! You don't HAVE to say "If (in8) = 0", it knows by default!
   low p10
   else
   high p10
endif

; Return to main loop
goto main


BasicMicro plans to produce more demo codes like this and release them to the various forums.
Check in often!
kenjj (BasicMicro)

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: Demo Code for Atom28(D) module, Atom Lab Board
PostPosted: Sat Jul 11, 2009 7:48 pm 
Offline
Master

Joined: Sun Oct 05, 2008 9:40 am
Posts: 111
Everything I have read states that this should compile but it does not using the new IDE. I have got it to work with the old IDE.

adin ax1, 0, ad_ron, voltsa

you have

adin AX3,temp

When I leave out the CLK and Adsetup I can get it to compile with the new IDE. What has changed?


Top
 Profile  
 
 Post subject: Re: Demo Code for Atom28(D) module, Atom Lab Board
PostPosted: Sat Jul 11, 2009 8:44 pm 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
This demo code is written for the latest compiler, Atom5315. The syntax for ADIN has been simplified to
ADIN pin, var_name
Confusion reigned with the old syntax, so this got simplified. Some of the syntax is wrong in the Atom manual 3002, and the Pro manual may have the proper syntax in these cases. Download the Atom Pro manual. When an Atom command fails to work as written, try it the Pro way.
The idea is to produce source code with common syntax and settings values so it all becomes seamless to use all Atom parts from one compiler (called Studio, which is in the works). Nice, huh? I thought so.

We are beating ourselves RIGHT NOW THIS MINUTE writing the new, all-inclusive manual for all the Atom products, including Pro. In fact, I checked the forums just now as a break from the manual. Short of brain aneurysms all around, I'm thinking this will be done in two to three weeks. Hey, maybe less!
Take care.

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: Demo Code for Atom28(D) module, Atom Lab Board
PostPosted: Sun Jul 12, 2009 9:41 am 
Offline
Master

Joined: Sun Oct 05, 2008 9:40 am
Posts: 111
Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO