Bus Communications
Discovery
Posts: 606
I need to send the binary equivalent of a decimal variable over an 8-bit bus.
The bus is formed using Propeller Pins
P0 Bus 0
P1 Bus 1
P2 Bus 2
P3 Bus 3
P4 Bus 4
P5 Bus 5
P6 Bus 6
P7 Bus 7
int i ranges from 0 to 255.
Is there a 'C' library instruction that does this simple task?
Sincerely,
Discovery
The bus is formed using Propeller Pins
P0 Bus 0
P1 Bus 1
P2 Bus 2
P3 Bus 3
P4 Bus 4
P5 Bus 5
P6 Bus 6
P7 Bus 7
int i ranges from 0 to 255.
Is there a 'C' library instruction that does this simple task?
Sincerely,
Discovery
Comments
https://propsideworkspace.googlecode.com/hg/Learn/Simple%20Libraries/Utility/libsimpletools/html/simpletools_8h.html#acbf5fe86eb36a02d4f86df2d3ca8d84d
You should be able to do what you're asking with this code:
I ran the following code on my Propeller Activity board.
i = 1;
set_outputs(7, 0, i);
and could not set any output pins.
I will try your write_to_bus instruction next.
Discovery
The write_to_bus(int i) code compiled correctly but did not set the pins.
i was set to various values 1, 2, 3...etc. but the pins remained low.
The pins do work via high(0)...etc.
Do you have a Propeller Activity Board you can run your code on to verify functionality?
Discovery
My fault...the write_to_bus works perfectly well.
I had to make i a static volatile int and the function works great.
Thank you.
Discovery
first to set pins 7:0 to outputs. You only need to do that once though at the beginning of your program, not every time you call set_outputs.
The set_directions instruction did the trick. Both of your suggestions work just fine.
Sincerely,
Discovery