Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

PULSEOUT problem

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
sielcon

Bascom Member



Joined: 16 Mar 2006
Posts: 74
Location: Argentina

argentina.gif
PostPosted: Sun Mar 17, 2024 8:23 pm    Post subject: PULSEOUT problem Reply with quote

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
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5922
Location: Holland

blank.gif
PostPosted: Mon Mar 18, 2024 10:07 am    Post subject: Reply with quote

as always, produce a small example that can be tested.
_________________
Mark
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Tue Mar 19, 2024 2:32 pm    Post subject: Re: PULSEOUT problem Reply with quote

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
View user's profile
sielcon

Bascom Member



Joined: 16 Mar 2006
Posts: 74
Location: Argentina

argentina.gif
PostPosted: Thu Mar 21, 2024 6:53 pm    Post subject: Sorry Reply with quote

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
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5922
Location: Holland

blank.gif
PostPosted: Thu Mar 21, 2024 8:38 pm    Post subject: Reply with quote

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
View user's profile Visit poster's website
sielcon

Bascom Member



Joined: 16 Mar 2006
Posts: 74
Location: Argentina

argentina.gif
PostPosted: Mon Mar 25, 2024 6:58 pm    Post subject: Reply with quote

Muchas gracias.
Back to top
View user's profile Visit poster's website
sielcon

Bascom Member



Joined: 16 Mar 2006
Posts: 74
Location: Argentina

argentina.gif
PostPosted: Mon Mar 25, 2024 6:59 pm    Post subject: Reply with quote

Sorry, I wrote it in Spanish. Thank you so much.
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum