Altera_Forum
Honored Contributor
16 years agoStrange behaviour whene reading custom component register
Hello,
I got a strange problem when reading the registers of a custom component in a Nios II/SOPC system. The system includes a Nios II/e cpu, on-board RAM, external SRAM, interval timer, JTAG-UART, PIO port and a custom component connected via Avalon-MM, called TemperaturePID. The system communicates with a PC terminal over the JTAG-UART. I wrote a device driver with IOWR and IORD functions for the TemperaturePID. I'm able to write and read the registers with this functions, but i found out, that a read-operation alters the register content. If I start the system and type in the command to read out the registers, the system outpus the initial values:IOS 0x00200010
Center frequency 25000
Temperature coefficient 94
Correction value 0
Temperature upper limit 200000
Temperature lower limit -200000
CTRL 0x0000000F
Setpoint 25000
Proportional gain 100
Integrator time 3.000
Derivation time 0.000
LPF coefficient 0 -1
LPF coefficient 1 1
Output upper limit 10638298
Output lower limit -10638298
Integrator limit 2147483647If I retype the command, i get this: IOS 0x001FFA37
Center frequency 2095665
Temperature coefficient 2095671
Correction value 2095675
Temperature upper limit 2095667
Temperature lower limit 2095679
CTRL 0x001FFA41
Setpoint 2095666
Proportional gain 2134092
Integrator time Inf
Derivation time 150.900
LPF coefficient 0 2095671
LPF coefficient 1 2095669
Output upper limit 2095669
Output lower limit 2095676
Integrator limit 2095677If I again retype the command, the values will be different, but stil in the range around 2090000 (decimal). I'am able to write new values in the register, again the first red operation shows the right values and the next read operation shows strange values. One thing my be interresting: the base-address of the component is 0x00209000 and the strange values are aroung 2090000 (decimal). Maybe this is just coincidence... This is the code-snipped that is responsible for the screen output: printf("Currently set values:\n\n");
printf("IOS\t\t\t0x%08X\n", IORD_TEMPERATUREPID_IOS(TEMPERATUREPID_0_BASE));
printf("Center frequency\t%d\n", IORD_TEMPERATUREPID_CTF(TEMPERATUREPID_0_BASE));
printf("Temperature coefficient\t%d\n", IORD_TEMPERATUREPID_TXC(TEMPERATUREPID_0_BASE));
...
printf("Integrator limit\t%d\n\n", IORD_TEMPERATUREPID_ILIM(TEMPERATUREPID_0_BASE));And this is the device-driver file: #ifndef __TEMPERATURE_PID_REGS_H__# define __TEMPERATURE_PID_REGS_H__
# include <io.h>
# define IORD_TEMPERATUREPID_IOS(base) IORD(base, 0x00) # define IOWR_TEMPERATUREPID_IOS(base, data) IOWR(base, 0x00, data)
# define IORD_TEMPERATUREPID_CTF(base) IORD(base, 0x01) # define IOWR_TEMPERATUREPID_CTF(base, data) IOWR(base, 0x01, data)
...
# endif /* __TEMPERATURE_PID_REGS_H__ */Does anybody have a clue what is going on here? If someone needs more information, please ask. Thanks i advance, magixD