I am using the H8s2318 micro and writing a programm in HEW.
I have setup the ABWCR register to use a 16 bit data bus, however when I write to a register on the connected FPGA it seems that a 16 bit value is written as two 8 bit values on two consecutive addresses.
The assembler code generated by the c compiler confirms this behaviour.
I have been looking everywhere in HEW to find an option to tell the compiler that it has to use a 16 bit data bus, but I couldn't find it. I have also tried using sections, but that also didn't give me an option to enter the data bus width.
I hope somebody can guide me in this.
There are no settings in HEW.
Bus accesses to external bus is translated inside the µC. Exception: you request byte accesses to 16-bit buswidth.
So, please show us your C-code to output data to the FPGA and your ABWCR settings too.
Thanks for you help.
This is the code:
#include "SYS_Cpu.h"
#include "SYS_types.h"
#define FPGA_CTRL_REG (*(volatile unsigned short * ) (0x050004))
//------------------------------------------------------------------------------
void main(void);
//------------------------------------------------------------------------------
void main(void)
{
unsigned long i;
for( ;; )
{
P1DR |= 0x08;
for( i =0; i!=500000; i++)
{
}
FPGA_CTRL_REG=0x0000;
P1DR &= ~0x08;
for( i =0; i!=500000; i++)
{
}
FPGA_CTRL_REG=0x0004;
}
}
AWBCR is set during init with:
ABWCR &= ~0x01;
I just had a little breakthrough by changing
#define FPGA_CTRL_REG (*(volatile unsigned short * ) (0x050004))
to
#define FPGA_CTRL_REG (*(volatile unsigned short __evenaccess * ) (0x050004))
this solved the problem, but I don't understand why this is neccessary and I think that there should be a better solution.
Besides from debugging this on target I also debug this with the SimSessionH8S-2000A debugger. In the Memory resources I set the address range from 0x050000 to read only. That way I get an Memory access error when running the programm which shows me exactly which memory addresses are accessed. With the original code I get a Memory access error on the addresses H' 00050004 and H' 00050005, but when I add the __evenaccess option it only access H' 00050004.
I was also in the opinion like you said that the µC will translate the bus access, but in my case the compiler already generated code that accesses two addresses.
I hope somebody can tell me what I am doing wrong so bus translation is handled by the µC.
Are you sure HEW uses the settings for H8S CPU?
I remember H8/3000 series, where you could use 1MB (or 16MB) memory space. Here address 0x50000 would direct to CS-area2 and not to CS-area0 as expected.
I am not sure what you mean, but when I look in the CPU tab on the toolchain it says: H8S/2000 Advanced 16M byte.
I have used the wizard to setup the project. The µC used is a H8s2318.
So please ignore my last thought.
©2003–2009 Renesas Technology Corp. All rights reserved. Using Our Website | Privacy
Contact us