View previous topic :: View next topic |
Author |
Message |
Triplett
Joined: 28 Feb 2010 Posts: 52 Location: Maryland

|
Posted: Mon Dec 04, 2017 7:13 pm Post subject: Is BITWAIT needed when reading the XMega RTC_PER register co |
|
|
I am sure this is a NOOB level question. A thousand pardons for any waste of bandwidth.
When an XMega changes the content of the RTC_PER register, there seems to be an odd behavior when reading back the updated value.
The behavior is mentioned in a related topic "Extending the powersave interval for the XMega," but the question about reading the register seems like a separate question.
The RTC_PER register has 16 bits, so the XMega A data sheet describes how to wait for the SYNCBUSY flag to reset before attempting to write a 16 bit value into the register. There seems to be no problem writing into the register by simply using a BITWAIT immediately before writing.
Reading back the stored values seems to fail, so I am picking through previous posts to see whether it is also necessary to wait for SYNCBUSY to reset before attempting to read the register. I hope it is that simple, but I'm not having much luck finding posts that hit it on the nail. If anyone knows or can point me to the correct discussion it would be greatly appreciated.
Regards,
Triplett
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
 |
Triplett
Joined: 28 Feb 2010 Posts: 52 Location: Maryland

|
Posted: Mon Dec 04, 2017 11:29 pm Post subject: Is BITWAIT needed when reading the XMega RTC_PER register? |
|
|
Yes. BITWAIT is needed immediately before reading the RTC_PER register. The code below shows it.
The remaining fine point in the code (mentioned in the related post) is that if we comment out the line that writes a 1 into the RTC_CTRL register, then the output text is the same but the system flashes one time per second.
If we put back the line that writes a 1 into the RTC_CTRL register, then the larger value for RTC_PER is effective and the system blinks one time each minute.
I faintly remember reading somewhere that the micro still needs to have the RTC_CTRL value updated in order to change blink rates. The code below proves it, but I just don't know where I read the information. It's been too long.
Code: |
$regfile = "xm32A4Udef.dat"
$crystal = 2000000
$hwstack = 64
$swstack = 40
$framesize = 40
Config Osc = Enabled, 32KHzosc = Enabled
Config Clock = Soft , Rtc = 1KHZ_INT32KHZ_RCOSC
Config Com1 = 115200 , Mode = Asynchroneous , Parity = None , Stopbits = 1 , Databits = 8
Config PortE.1 = Output ' LED
Config Priority = Static , Vector = Application , Lo = Enabled
Enable Interrupts
DIM RTC_PER_TEMP As Word
' Write values into registers.
BITWAIT RTC_STATUS.0, RESET : RTC_PER = 61439 ' This is 1110111111111111 in binary.
BITWAIT RTC_STATUS.0, RESET : RTC_CTRL = 1
' Show a simple fetch that fails.
Print "RTC_PER = "; BIN(RTC_PER)
' Show the fetch that works.
BITWAIT RTC_STATUS.0, RESET : RTC_PER_TEMP = RTC_PER
Print "RTC_PER_TEMP = "; BIN(RTC_PER_TEMP) '
' Allow printing to finish before going into powersave.
Print ""
Waitms 1
Do
SET PORTE.1
WAITMS 10 ' Flash once each minute (not second).
RESET PORTE.1
Config Powermode = Powersave ' Sleep one minute.
Loop
End
' Output is as follows:
' RTC_PER = 1111111111111111
' RTC_PER_TEMP = 1110111111111111
|
|
|
Back to top |
|
 |
albertsm
Joined: 09 Apr 2004 Posts: 6198 Location: Holland

|
Posted: Tue Dec 05, 2017 12:47 pm Post subject: |
|
|
I did not read the topic but what i found odd when doing research :
Bitwait Rtc_status.0 , Reset
Rtc_per = some value
Rtc_comp = 0 ' this is required even while it is 0
Rtc_ctrl = 1
while the docs are usually really good, i see that humans work at atmel/microchip. They also do copy/paste/edit (forget to edit) . Especial the data file sometimes have registers not found in the processor.
Early xmega have huge lists of errata. Make sure to check the revision number and the data sheet. Sometimes it is listed. But sometimes you need to report an issue. (when it is an issue). _________________ Mark |
|
Back to top |
|
 |
|
|
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
|
|