Offset value and reset value

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi to all, may i know,what is difference between offset value and reset value of  register of a controller?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

They don't have anything to do with one another.

The offset value would be the address of the register, perhaps (on xmega or ARM) relative to the base address of the peripheral.  Reset value is the contents of the peripheral register after reset.   (so on an ATtiny814) USART0 is at base address 0x800, CTRLC is at offset 7 (address 0x807), and the reset value is 0b00000011 (Async, parity disabled, 1stopbit, datasize = 8bit)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Exactly. The reset value is basically the default value for that register. When it's not specified, you should assume it resets to a random value and needs to be initialized.

I'd say most people, however, initialize all registers they intend to use even if they need the reset value, just in case.

 

You can find the module base addresses in the datasheet, but the best way is to get them from the include files, for example, here is an excerpt from the Tiny1614 assembly include file (tn1614def.inc):

 

; ***** ALL MODULE BASE ADRESSES *****************************************

.equ AC0_base = 0x0680                   ; Analog Comparator
.equ AC1_base = 0x0688                   ; Analog Comparator
.equ AC2_base = 0x0690                   ; Analog Comparator
.equ ADC0_base = 0x0600                  ; Analog to Digital Converter
.equ ADC1_base = 0x0640                  ; Analog to Digital Converter
.equ BOD_base = 0x0080                   ; Bod interface
.equ CCL_base = 0x01C0                   ; Configurable Custom Logic
.equ CLKCTRL_base = 0x0060               ; Clock controller
.equ CPU_base = 0x0030                   ; CPU
.equ CPUINT_base = 0x0110                ; Interrupt Controller
.equ CRCSCAN_base = 0x0120               ; CRCSCAN
.equ DAC0_base = 0x06A0                  ; Digital to Analog Converter
.equ DAC1_base = 0x06A8                  ; Digital to Analog Converter
.equ DAC2_base = 0x06B0                  ; Digital to Analog Converter
.equ EVSYS_base = 0x0180                 ; Event System
.equ FUSE_base = 0x1280                  ; Fuses
.equ GPIO_base = 0x001C                  ; General Purpose IO
.equ LOCKBIT_base = 0x128A               ; Lockbit
.equ NVMCTRL_base = 0x1000               ; Non-volatile Memory Controller
.equ PORTA_base = 0x0400                 ; I/O Ports
.equ PORTB_base = 0x0420                 ; I/O Ports
.equ PORTC_base = 0x0440                 ; I/O Ports
.equ PORTMUX_base = 0x0200               ; Port Multiplexer
.equ RSTCTRL_base = 0x0040               ; Reset controller
.equ RTC_base = 0x0140                   ; Real-Time Counter
.equ SIGROW_base = 0x1100                ; Signature row
.equ SLPCTRL_base = 0x0050               ; Sleep Controller
.equ SPI0_base = 0x0820                  ; Serial Peripheral Interface
.equ SYSCFG_base = 0x0F00                ; System Configuration Registers
.equ TCA0_base = 0x0A00                  ; 16-bit Timer/Counter Type A
.equ TCB0_base = 0x0A40                  ; 16-bit Timer Type B
.equ TCB1_base = 0x0A50                  ; 16-bit Timer Type B
.equ TCD0_base = 0x0A80                  ; Timer Counter D
.equ TWI0_base = 0x0810                  ; Two-Wire Interface
.equ USART0_base = 0x0800                ; Universal Synchronous and Asynchronous Receiver and Transmitter
.equ USERROW_base = 0x1300               ; User Row
.equ VPORTA_base = 0x0000                ; Virtual Ports
.equ VPORTB_base = 0x0004                ; Virtual Ports
.equ VPORTC_base = 0x0008                ; Virtual Ports
.equ VREF_base = 0x00A0                  ; Voltage reference
.equ WDT_base = 0x0100                   ; Watch-Dog Timer

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd say most people, however, initialize all registers they intend to use even if they need the reset value, just in case.

Really?  I hardly ever see code posted that initializes the registers of peripherals that aren't used - that's actually relying on quite a LOT of default behavior.  (Some of the microchip PICs initialize some pins to analog mode, so you have to go and set up some ADC and/or AC configuration before you can do basic BLINK-type functions.  It's a bit of an eye-opener!)

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks westfw and El Tangas.