How to configure digital output in Renesas RH850/FIL Micrcontroller ?

I need to configure pin AP0_14 for digital output. To achieve this I need to write 0 to bit 14 of 16-bit Port Mode Register.

The physical address of this register is: 0xFFC103C8

What should be the exact statement to write to this register using the physical address ?

--------------------------------------- Posted through

formatting link

Reply to
Loading thread data ...


First, before you read any more, your tools should have come with header files that give you macro files, structure definitions, or something to do this. You should find them and use them.

If that doesn't float your boat, read on.

There are lots and lots of ways to do this, ranging from the correct but ugly, through pretty but wrong, and back to correct, but pretty this time. Which "should" are you interested in?

Ugly but effective (I think -- try this) in C is

*(uint16_t *)(0xffc103c8) &= 0xdfffffff;

In C++ that'll give you compiler warnings, so you change it to

*static_cast(0xffc103c8) &= 0xdfffffff;

except that you're being loosey-goosey with the standard, so you may need to use

*reinterpret_cast(0xffc103c8) &= 0xdfffffff;

A _far far_ better way to do it is to make a bitmapped structure, map it to the correct memory location in your linker file or in an assembly file, and then change the one bit explicitly. Assuming that the bit enables the gzorgle, you'll end up with something like


Tim Wescott 
Wescott Design Services 
 Click to see the full signature
Reply to
Tim Wescott

It's not homework. I need to toggle output pin to measure task rate. Thank you for the solution. I'll try it. Don't I need a volatile keyword ?

--------------------------------------- Posted through

formatting link

Reply to

Yes, you need "volatile" - so you would have something like this:

*(volatile uint16_t *)(0xffc103c8) &= 0xbfff;

or, better,

*(volatile uint16_t *)(0xffc103c8) &= ~0x4000;


*(volatile uint16_t *)(0xffc103c8) &= ~(1u
Reply to
David Brown







OK. Initially, I had 32-bit value on the right hand side. Switching to

16-bit worked fine.

Thanks very much.

--------------------------------------- Posted through

formatting link

Reply to

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.