We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
I have a Philips RD2 board with a memory mapped 8255 with ports A at 8000H, B at 8001H, C at 8002H and a control port at 8003H.
How do I set up my defines so that I can just refer to these memory mapped ports as PORTA, CTRLPRT etc. in a C program?
Muz
An 8255? Yes, that is embarrassing!
Take a look at: http://www.keil.com/support/man/docs/c51/c51_le_absvarloc.htm http://www.keil.com/support/man/docs/c51/c51_le_memtypes.htm
An 8255? Yes, that is embarrassing! yes, very embarassing. for more " href= "http://www.8052.com/faqs.phtml?FAQ=119928">www.8052.com/faqs.phtml
which antique dealer sold it to you?
Erik
Hello Erik and Andy,
Thanks very much for the prompt replies to my message. I overlooked the _at_ thingy thinking that there may be some fancy way of adressing the port with a define. I used the _at_ memory addressing method and it works just fine. Thanks.
Thanks also for the heads up about the 8255 being a little slow. If I get into trouble, then I'll know to put some delays in there.
Muz.
If you wanted to use a #define, it would look something like:
8255.h -- #define 8255_BASE_ADDR 0x8000 #define 8255_CTRL_ADDR (8255_BASE_ADDR + 3) #define 8255_CTRL (*(xdata volatile*)8255_CTRL_ADDR) ... // usage val = 8255_CTRL; 8255_CTRL |= 0x01;
The only virtue of this method would be portability. (And that not so much of the code, but of your skills; you don't have to figure out the current platform's idiosyncratic method of locating variables for each project.) _at_ should work just fine.
I overlooked the _at_ thingy in other words you are connecting the antique as memory mapped I/O
If I get into trouble, then I'll know to put some delays in there. the problem is it makes no difference. The width of !WR and !RD can not be changed except by clock frequency (or using a derivative with programmable timing (I believe Dallas has such, SILabs does but they are 3V3 and the antique is a 5V device).
I should have a couple of those about 20 years below the dust :)
Hi Drew,
Oh, thank you. That's the kind of thing I was after.
I can't seem to make it go, though. I get a bunch of syntax errors.
Hi Erik,
Thanks for the reply.
Ah, I see. It's a RD and WR signal timing issue. Well the 8255's are on a commercially produced development board that I'm helpng a friend get started with. I guess they have any hardware signal timing issues sorted out in the design, so I won't bother with software delays then.
when the 8255 was 'standard', every darn thing you made had to be 'tuned' except, of course, those with the psd chips instead. I believe I still have scars from touching the original 'steam driven' '51s oh how Impressed I was about their screaming 8 MHz performance. ICEs were complicated, the '51s were dynamic and could not be stopped without 'losing their mind'. Oh, you young whippersnappers, you have an easy life.
These days, with modern devices, I am almost in the opposite ditch, things work so seamlessly that I almost get surprised when checking timings show anything but "this will work with a wide tolerance".
"The only virtue of this method would be portability ... _at_ should work just fine"
And the advantage of _at_ is that the tools know exactly what you're doing - so, for example, there's no risk of the Linker allocating some variable(s) at the same address...
"I overlooked the _at_ thingy thinking that there may be some fancy way of adressing the port"
It's not a port - it's just a memory address.
That's why it's called "memory-mapped"
It appears that he is trying to emulate a DOS driven AT port for a DIO board using the 8051. Suggest that you do a inet search on DIO boards. I'm sure that you will find some old documentation with timing demonstrated. By the way Erik, you are not the oldest timer here. I first started on computers when John von Neumann was still alive. Of course we called him Janci. Just not digital computers for me at the time. ;-). Bradford
By the way Erik, you are not the oldest timer here well, since I do not know your age, and you do not know mine I can't argue the point. However, we both, evidently, have ages of experience. When I went to college the main electronic component was somewthing called 'tubes' or 'valves' and after collegte I was involved with making the first transistor radio made in Denmark.