Forum

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

   

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
How to write to a port?
2015 年 10 月 19 日
05:16:28
General Suntzu
New Member
Forum Posts: 5
Member Since:
2015 年 10 月 17 日
Offline

Is there an example on writing and reading to a port?

For to win one hundred victories in one hundred battles is not the acme of skill. To subdue the enemy without fighting is the acme of skill.
2015 年 10 月 22 日
18:20:55
cucubutter
Moderator
Forum Posts: 84
Member Since:
2014 年 04 月 10 日
Offline

Hi, General Suntzu:

we can do it by IO function : outpb()

ex:
For 86Duino, the IO address of GPIO port 0 DATA register is 0xf200, and the IO address of GPIO port 0 DIR register is 0xf202, we want to set pin 0 and pin 2 to HIGH, other pins to LOW, do as following :

outpb(0xf202, 0xff); // set DIR register to 0xff (set all pins of GPIO port 0 are OUTPUT)
outpb(0xf200, 0x05); // set DATA register to 0x05 (pin 0 and pin 2 to HIGH, other pins to LOW)

cucubutter

2015 年 11 月 19 日
02:52:21
General Suntzu
New Member
Forum Posts: 5
Member Since:
2015 年 10 月 17 日
Offline

Thanks cucubutter.
Can you also show me how to write to the other ports 1-9?
I need the offsets for each one, so if you have the info that would be great. An example like above would be even better.

For to win one hundred victories in one hundred battles is not the acme of skill. To subdue the enemy without fighting is the acme of skill.
2015 年 11 月 20 日
10:53:02
cucubutter
Moderator
Forum Posts: 84
Member Since:
2014 年 04 月 10 日
Offline

Hi, General Suntzu:

Refer the post to know GPIO port 0-9 DIR and DTAT register address.

On 86Duino, i found the "DIR register address" of GPIO port 0 is 0xF202, and GPIO port 1 is 0xF206, GPIO port 2 is 0xF20A ...
The DATA register address of GPIO port 0 is 0xF200, and GPIO port 1 is 0xF204, GPIO port 2 is 0xF208 ...

If we want to set GPIO port 0-9 to output 0x05, a example as below:

// GPIO port 0
outpb(0xf202, 0xff);
outpb(0xf200, 0x05);

// GPIO port 1
outpb(0xf206, 0xff);
outpb(0xf204, 0x05);

// GPIO port 2
outpb(0xf20A, 0xff);
outpb(0xf208, 0x05);

// GPIO port 3
outpb(0xf20E, 0xff);
outpb(0xf20C, 0x05);

// GPIO port 4
outpb(0xf212, 0xff);
outpb(0xf210, 0x05);

// GPIO port 5
outpb(0xf216, 0xff);
outpb(0xf214, 0x05);

// GPIO port 6
outpb(0xf21A, 0xff);
outpb(0xf218, 0x05);

// GPIO port 7
outpb(0xf21E, 0xff);
outpb(0xf21C, 0x05);

// GPIO port 8
outpb(0xf222, 0xff);
outpb(0xf220, 0x05);

// GPIO port 9
outpb(0xf226, 0xff);
outpb(0xf224, 0x05);

cucubutter

2015 年 11 月 22 日
00:55:50
General Suntzu
New Member
Forum Posts: 5
Member Since:
2015 年 10 月 17 日
Offline

Thanks cucubutter. Thanks.

For to win one hundred victories in one hundred battles is not the acme of skill. To subdue the enemy without fighting is the acme of skill.
Forum Timezone: Asia/Taipei

Most Users Ever Online: 66

Currently Online:
2 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Dinosaur: 27

leutenecker: 13

mrZagg: 10

lukeross: 8

tomka: 8

smeezekitty: 8

hippy: 8

Ekkehard: 8

UIdahoCIT: 8

blaxxun: 7

Member Stats:

Guest Posters: 0

Members: 1509

Moderators: 14

Admins: 5

Forum Stats:

Groups: 2

Forums: 10

Topics: 238

Posts: 1079

Newest Members: Carol Chou, Kai-Jung Chou, 1789, RegLiu, ameerawwad, asmanko, nekotwingo, ttronic, Davidpag, zaskia12

Moderators: Glaux: 70, uaa: 11, guigra: 17, asian55: 22, Android_Lin: 208, bcarroll: 12, cucubutter: 84, recycled-air: 12, stevemork: 16, zerozaber: 52, pongraczi: 20, George Andrews III: 56, poto: 11, garpastym: 20

Administrators: eveshih: 1, anthony: 31, viky6: 0, roboard: 135, hcl: 0