[C.CC USERS] Progress so far.. The ADC?
Matt Jadud
matt at jadud.com
Tue Jul 9 18:19:51 BST 2013
Hi Peter,
All good to know. I'll take a poke, now that I own an Uno. I am curious as
to why the Windows version would do anything differently, because so little
is taking place on the local machine.
If it compiled OK, that means the register is defined. I've moved the
library to
https://github.com/concurrency/plumbing
out of the main occam codebase, because the library really is a set of pure
occam tools, and isn't tightly coupled to the (larger) tree. The defined
registers are in
https://github.com/concurrency/plumbing/blob/master/src/arch/m328p/iom328p.inc
which is automatically converted via Perl script from the C header file, so
it should be 1) correct and 2) complete.
I haven't touched the SPI for a few days, but the nice thing is that there
is no difference between a "library" and the code you write. So, anything
you write can become a library simply by putting it in the compiler's
include path.
Also, worth noting:
When you do an upload using the IDE, it uploads all of the occam (.occ)
files in the directory that you're compiling from. So, if you have three
files:
a.occ
b.occ
c.occ
all three will be uploaded when you compile a.occ. (Only .occ, .inc, and
.module files are uploaded this way.) If "a" references "b" or "c" via
#INCLUDE, it will work. This may be useful to you. It is *not* smart,
however: it only grabs things within the directory of the file you're
actively compiling.
More later, when I get a chance to poke things with a stick, and see what
is up with the Windows side.
Cheers,
Matt
On Tue, Jul 9, 2013 at 10:36 AM, Dr Peter D Minns
<minns627 at btinternet.com>wrote:
> Hi Matt
>
> Hope things are OK with you.
>
> The Plumb (28/june version) software looks good and is working fine for my
> programs so far.
>
> Seems to be problem with the Windows version (same as was happening with
> the MAc version) in that we get a syntax error when compiling programs
> that compile fine on the mac version.
>
> Was trying to produce occam code for the ADC but have not had any success
> so far.
>
> I started out trying your "Plumbing" PROCs but with no success.
>
> I then tried making up an occam program using a similar arrangement I had
> used in C with the Arduino IDE.
>
> Here it is :
>
> -- raw adc using ATMEL registers:
> #INCLUDE "plumbing.module"
>
> PROC main()
> SEQ
> PLACED [1]BYTE admux ADMUX:
> PLACED [1]BYTE adcsra ADCSRA:
> PLACED [1]BYTE adcsrb ADCSRB:
> PLACED [1]BYTE didr0 DIDR0:
> PLACED [1]BYTE didr1 DIDR1:
> PLACED [1]BYTE adcl ADCL:
> PLACED [1]BYTE adch ADCH:
> PLACED [1]BYTE ddrd DDRD:
> PLACED [1]BYTE portd PORTD:
>
>
> SEQ
> admux[0] := #40 --ref is 5V, sel ch 0
> adcsra[0] := #86 --Enable ADC, prescalor x 64
> adcsrb[0] := #00 --not using auto-triggering
> --didr0[0] := #3F -- disable digital inputs.
> --didr1[0] := #03 -- likewise to 000 0011
> ddrd[0] := #FF -- portd all outputs.
> adcl[0] := 0
> adch[0] := 0
> portd[0] := #00 -- initialise to zero.
> BYTE result:
> --[2]BYTE bytes RETYPES result:
> BOOL going :
> WHILE TRUE
> SEQ
> going := TRUE
> adcsra[0] := 1 << ADSC -- start conversion. Tried 6 as well
> WHILE going
> SEQ
> IF
> ADSC > 0
> SEQ
> going := FALSE
>
>
> result := adcl[0]
> portd[0] := BYTE result
> TRUE
> SKIP
>
>
> :
>
> I also tried your ports[REG] := #value as in ports[ADMUX] := #40
> But did not work either (compiled OK).
>
> Perhaps these registers have not yet been added to the compiler?
>
> In C I could use pointers to addresses names, or ATMEL names but as far as
> I am aware there is no equivalent in occam.
>
> You appear to be using the ATMEL register names for ports as portb, portd
> ext.
>
> I know you said you were working on the SPI so perhaps I should try that
> first. I have a C program for the SPI that I can translate to occam and
> try it out. Is this available with Plumb version 20130628?
>
>
>
>
> Peter
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.concurrency.cc/pipermail/users/attachments/20130709/e65f096f/attachment-0001.htm>
More information about the users
mailing list