Altera_Forum
Honored Contributor
20 years agoRead and write 16 bits device via Avalon
Hi there,
I have create a SOPC Builder component to have access to a USB peripheral controller. This USB controller has a 16 bits data bus et one address line (2 addresses: '0' and '1'). My SOPC component use clk, irq, chipselect, read, write, address, readdate and writedate signals from Avalon bus. For the software driver, I use IOWR_16DIRECT() and IORD_16DIRECT() macro functions from io.h. With this I got following behavior:[list][*]IOWR_16DIRECT(BASE_ADDRESS, 0, 0xffff): write access on address '0' (correct) [*]IOWR_16DIRECT(BASE_ADDRESS, 1, 0xffff): write acces on address '0' and address '1' (incorrect) [*]IORD_16DIRECT(BASE_ADDRESS, 0): read access on address '0' and address '1' (incorrect) [*]IORD_16DIRECT(BASE_ADDRESS, 1): read access on address '0' and address '1' (incorrect) [/list] I changed the READ and WRITE macro to this one:#define IOWR16(ADDRESS, OFFSET, VALUE) *(((volatile unsigned short *)(ADDRESS)) + (OFFSET)) = (VALUE)# define IORD16(ADDRESS, OFFSET) *(((volatile unsigned short *)(ADDRESS)) + (OFFSET)) Now I got following behavior:[list][*]IOWR16(BASE_ADDRESS, 0, 0xffff): write access on address '0' (correct) [*]IOWR16(BASE_ADDRESS, 1, 0xffff): write acces on address '1' (correct) [*]IORD16(BASE_ADDRESS, 0): read access on address '0' and address '1' (incorrect) [*]IORD16(BASE_ADDRESS, 1): read access on address '0' and address '1' (incorrect) [/list] Any suggestions how I can erase the unwanted read access ? Regards Fabrice