View previous topic :: View next topic |
Author |
Message |
sielcon
Joined: 16 Mar 2006 Posts: 74 Location: Argentina
|
Posted: Sun Mar 17, 2024 8:23 pm Post subject: PULSEOUT problem |
|
|
Hello everyone, doing tests with the ATMEGA2560 I was able to verify that PULSEOUT does not work on the PORTH.6 port, I did it with SET and RESET and it works correctly, then I changed to PORTD.3 and PULSEOUT works again. Since I did not find any reference to port exclusion for PULSEOUT in the HELP, I report it.
Kind regards.
(BASCOM-AVR version : 2.0.8.6 , Latest : 2.0.8.6 ) |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5922 Location: Holland
|
Posted: Mon Mar 18, 2024 10:07 am Post subject: |
|
|
as always, produce a small example that can be tested. _________________ Mark |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Tue Mar 19, 2024 2:32 pm Post subject: Re: PULSEOUT problem |
|
|
sielcon wrote: | I was able to verify that PULSEOUT does not work on the PORTH.6 port |
You are correct, neither it works on Port-J, -K, and -L.
The reason is twofold, first, calling code of PulseOut() omits to set XH, second MCS.lib kills XH, even if it would be set correctly.
Code: | #IF _XMEGA=0 and _XTINY=0
Clr Xh
#ENDIF |
Because of this a PulseOut PORTH, 6, 1000 writes accidentally to processor register R2, instead to PORTH at 0x0102.
ATM2560 places a bunch of registers at or above IO 0x0100, among these registers are Port H to L.
To address these registers via LD/ST X, XH register must be set accordingly. |
|
Back to top |
|
|
sielcon
Joined: 16 Mar 2006 Posts: 74 Location: Argentina
|
Posted: Thu Mar 21, 2024 6:53 pm Post subject: Sorry |
|
|
Code: |
$regfile = "m2560def.dat"
$crystal = 16000000
$hwstack = 40
$swstack = 16
$framesize = 32
Config Submode = New
$baud = 19200
Dim Pulsos , Count_pulso As Word
Config Porth.6 = Output
Config Porth.5 = Input
Reset Porth.6
Const Carga_t2 = 7
Pulsos = 133
Config Timer2 = Timer , Prescale = 1024
On Timer2 Int_t2
Timer2 = Carga_t2
Enable Timer2
Start Timer2
Enable Interrupts
Do
Loop
Sub Int_t2
Load Timer2 , Carga_t2
Start Timer2
If Count_pulso > 1 Then
Decr Count_pulso
Else
Pulseout Porth , 6 , 4000
Count_pulso = Pulsos
End If
End Sub
End
|
|
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5922 Location: Holland
|
Posted: Thu Mar 21, 2024 8:38 pm Post subject: |
|
|
yes MWS is right. there was no provision for extended ports (ports with a word address).
to be efficient addressable most ports are on a low address. but newer chips used extended space for additional ports.
old AVR only required 1 byte to be set. with multiple calls it is more efficient to set the high byte to 0 in the lib.
but for the 2087 release it was solved different. _________________ Mark |
|
Back to top |
|
|
sielcon
Joined: 16 Mar 2006 Posts: 74 Location: Argentina
|
Posted: Mon Mar 25, 2024 6:58 pm Post subject: |
|
|
Muchas gracias. |
|
Back to top |
|
|
sielcon
Joined: 16 Mar 2006 Posts: 74 Location: Argentina
|
Posted: Mon Mar 25, 2024 6:59 pm Post subject: |
|
|
Sorry, I wrote it in Spanish. Thank you so much. |
|
Back to top |
|
|
|