View previous topic :: View next topic |
Author |
Message |
nisse
Joined: 14 Dec 2006 Posts: 50
|
Posted: Sun Jan 13, 2013 9:16 pm Post subject: 1wire on extended port not working |
|
|
Hi
I'm trying to use 1wire on pinf.6 but it doesn't work.
Same code works fine on pind.0 and d.1
I have atmega128 in 128 mode, Bascom 2.0.7.6.001
Extended = 1 or 0 makes no difference.
Not using the ADC or jtag
I'm stuck
Any suggestions?
/Andy |
|
Back to top |
|
|
kimmi
Joined: 24 Feb 2006 Posts: 1922 Location: Denmark
|
Posted: Sun Jan 13, 2013 11:34 pm Post subject: |
|
|
Hi Andy
did you connect both set of Vcc gnd PIN 21 22 / 52 53 ?
not sure if you need to connect Avcc and gnd to 63 64 _________________ / Kim |
|
Back to top |
|
|
nisse
Joined: 14 Dec 2006 Posts: 50
|
Posted: Mon Jan 14, 2013 7:17 am Post subject: |
|
|
yes, there all connected |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 6025 Location: Holland
|
Posted: Mon Jan 14, 2013 10:05 am Post subject: |
|
|
always try some some code that toggles the pin so you can determine if you can really control the pin :
config portF.6 =output
do
toggle portF.6
waitms 1000
loop
then measrure level of portf.6
also check if timing is correct _________________ Mark |
|
Back to top |
|
|
kimmi
Joined: 24 Feb 2006 Posts: 1922 Location: Denmark
|
Posted: Mon Jan 14, 2013 1:18 pm Post subject: |
|
|
Just tested in ISIS
PortF.6 not working
but I see that portE.6 is activ ???
if I connect portf.6 and porte.6 to my 1 wire I get data OK
can it be a error in m128def.dat or mcs.lib 1Wire ?
Of cause it can be a internal error in ISIS to !!!
@Edit the error was in ISIS
PINE = $00
PINF = $01
thats wrong
PINE = $01
PINF = $00 _________________ / Kim |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 6025 Location: Holland
|
Posted: Mon Jan 14, 2013 1:45 pm Post subject: |
|
|
I looked it up:
it will not work for the m128 portF because it has an odd port map :
PINF = $00
PORTF = $62
DDRF = $61
The 1wire depends on the fact that the port/pin/ddr are grouped like pin,ddr,port:
PORTD = $12
DDRD = $11
PIND = $10
it would require a special version of the lib for the m128 portF. _________________ Mark |
|
Back to top |
|
|
nisse
Joined: 14 Dec 2006 Posts: 50
|
Posted: Mon Jan 14, 2013 1:54 pm Post subject: |
|
|
ok, thanks Mark and Kim, but isn't this what extended=1 is supposed to solve?
/Andy |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 6025 Location: Holland
|
Posted: Mon Jan 14, 2013 1:56 pm Post subject: |
|
|
no, that only resolve the case where the address is >&HFF. Like $100. In that case R31 must be set too. _________________ Mark |
|
Back to top |
|
|
nisse
Joined: 14 Dec 2006 Posts: 50
|
Posted: Mon Jan 14, 2013 2:01 pm Post subject: |
|
|
ok ic
How would you suggest I go about getting a special version of the lib for the m128 portF?
/Andy |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 6025 Location: Holland
|
Posted: Mon Jan 14, 2013 11:08 pm Post subject: |
|
|
- open mcs.lib
- copy the code from [1wire] and put it in a new lib
- then look for the code that uses the PIN register :
for example :
Ld r17,Z ; get PIN register
change that like:
Lds r17, PINF
i think it is used twice.
then use $lib to include the modded lib. that should do it. _________________ Mark |
|
Back to top |
|
|
kimmi
Joined: 24 Feb 2006 Posts: 1922 Location: Denmark
|
Posted: Tue Jan 15, 2013 2:03 am Post subject: |
|
|
You also need to edit the DDR and PORT
and if you use 1wireserach you must edit [1WIRE_SEARCH] to _________________ / Kim |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 6025 Location: Holland
|
Posted: Tue Jan 15, 2013 10:19 am Post subject: |
|
|
it should not be needed to change ddr and port but because PIN address is passed which is 0 , you should add $60 to Z.
you could do that by modding this:
_1wire_set_pin:
ldi r30,$60 ; fixed
clr 31 ; fixed
Ld r16,z+1 ; get DDR register
then you do not need to change ddr/portf code. _________________ Mark |
|
Back to top |
|
|
nisse
Joined: 14 Dec 2006 Posts: 50
|
Posted: Tue Jan 15, 2013 2:06 pm Post subject: |
|
|
Thanks guys, I'll give it a go.
Haven't done any assembler programming since the 6502, 30 years ago, but its a bit like riding a bike, isn't it
/Andy
PS, does the changes you mention apply to all 1wire routines or just the _1wire_set_pin routine? |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 6025 Location: Holland
|
Posted: Tue Jan 15, 2013 2:39 pm Post subject: |
|
|
it will work for all since they all use this routine first. so the changes are minimal. _________________ Mark |
|
Back to top |
|
|
nisse
Joined: 14 Dec 2006 Posts: 50
|
Posted: Wed Jan 16, 2013 6:57 pm Post subject: |
|
|
Sorry guys, stuck again
I've copied the [1_WIRE] part from mcs.lib into a new text file, 1wireF.lib
and use $lib "1wireF.lib" in the code.
When compiling I get .DEF not found and Backward jump out of range
@ lib code removed ! |
|
Back to top |
|
|
|