Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Porting code from 8-bit to 32-bit platform

Status
Not open for further replies.

techie

Advanced Member level 3
Joined
Feb 5, 2002
Messages
839
Helped
58
Reputation
116
Reaction score
9
Trophy points
1,298
Location
Pakistan
Activity points
7,802
I am porting a few applications from 8051 to ARM7. Can someone answer the following:

1. Is there a 16-bit variable avaialable in 32-bit ARM. The equivalent of unsigned int in 8051.

2. If I have an LCD display data bus connected to P0.16-P0.23 (8 bits of a 32bit port), what is the best way to write to this 8-bit portion of 32 bit port without disturbing the rest of the databus

3. What is the best way to read P0.16-P0.23 into an 8-bit variable (unsigned char).

4. One port pin is bidirectional requiring direction change quite often. It is difficult to keep track of the direction of other pins and toggle just this pin. Is there a better way to do that. Like for example, making a port pin high requires no knowledge of existing state of other pins on the same port and you can just write IOSET0 = 0x00001000 to set pin 0.15. Is there a similar way to change the direction.
 

Mindaugasu

Member level 3
Joined
Apr 17, 2005
Messages
66
Helped
7
Reputation
14
Reaction score
3
Trophy points
1,288
Activity points
1,753
1. You can use uint16_t types as 16 bit variables from "types.h" library;
2. One solution could be using mask.
uint8_t LCDdata, temp;
uint32_t mask=0xFF0F;
temp=IOPIN0;
temp=temp&mask;
IO0SET=mask|((uint32_t)(LCDdata>>16)); //sets desired ones to P0.16-P0.23
Hope you get the idea.
3. reading can be done like this:
uint8_t data8;
uint32_t read32;
read32=IOPIN0;
data8=(uint8_t)(read32>>16);
4. use construction like:
IODIR0 |= (1<<15); // define Pin as output
IOSET0 = (1<<15); // set Bit
IODIR0 &= ~((1<<15); // define Pin as input

They are just my ideas that came at the moment. Maybe there are more better suggestions.
---------------
www.scienceprog.com
 

    techie

    Points: 2
    Helpful Answer Positive Rating

techie

Advanced Member level 3
Joined
Feb 5, 2002
Messages
839
Helped
58
Reputation
116
Reaction score
9
Trophy points
1,298
Location
Pakistan
Activity points
7,802
Can you post some sample code.

Suppose the P0.16-P0.23 is initially = 0xaa;
You want to put the data 0x55 on this.

If you IO0SET=mask|((uint32_t)(LCDdata>>16));

Then P0.16-P0.23 will become 0xff since you have ORed 0xaa to 0x55. Wouldnt you need to first make the port area = 0x00 and then OR it with new data. But that looks so cumbersome.

Do you have usefull macro's to do this in a simple one line manner.

I miss the 8051.

P0 = i;
i = P0;
if (P0.3 == 0) .....
P0.3 = 1;
P0.3 = 0;
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top