digOutBank not working

Hello,

I tested the DIGOUT_BANK.C sample and it works fine (BL4S200). The demo begins by configuring the first 8 channels as outputs, and then uses digOutBank() to set or clear the selected output.

If I configure channel 0 as an input and the 7 other channels as outputs, why the calls to digOutBank() have no effect on the output pins? In the documentation of digOutBank():
“This function only updates the channels that are configured to be sinking digital outputs by the setDigOut() function call. Channels configured for other functionality will not be affected.”

That seems to imply that we can have an input in a given bank, and the function will only change the pins configured as outputs.

Anyone knows why this behavior? Anything I’m doing wrong?

Thank you
Simon

There may be a bug, or just an unmet usage requirement from the libraries that results in that behavior.

You could define the macro RSB_VERBOSE in your program and watch the STDIO output for any warnings or indications that there’s something about the configuration that the library doesn’t like.

You might also want to check the return value of your setDigIn() and setDigOut() calls to see if they’re returning errors.

I’m not intimately familiar with the libraries involved (BLxS2xx.LIB and RIO_SBC.LIB), but I think that output should help you track down the root cause. You could also take a look a some of the variables that store the I/O configuration and compare their values when calling setDigOut() before setDigIn() to identify possible culprits.

If there’s a library bug, let me know and I’ll work on fixing it.

I get the following with RSB_VERBOSE. No error is logged.

_riosbc_Toggled channel 20), f/f(6,00) returns 0.                               
_riosbc_set_pin(0,4,1) set to state 1.                                          
__riosbc_set_block(0,4,0) set to incorrect function (0).                        
_riosbc_set_block(1,0) set to setting ff (05).                                  
_riosbc_set_function(0,4,2), f/f(6,00) returns 0.                               
_riosbc_set_pin(0,4,3) set to state 1.                                          
_riosbc_set_function(0,4,3), f/f(6,00) returns 0.                               
_riosbc_set_pin(1,0,0) set to state 1.                                          
_riosbc_set_function(1,0,0), f/f(6,00) returns 0.                               
_riosbc_set_pin(1,0,1) set to state 1.                                          
_riosbc_set_function(1,0,1), f/f(6,00) returns 0.                               
_riosbc_set_pin(1,0,2) set to state 1.                                          
_riosbc_set_function(1,0,2), f/f(6,00) returns 0.                               
_riosbc_set_pin(1,0,3) set to state 1.                                          
_riosbc_set_function(1,0,3), f/f(6,00) returns 0.                               
_riosbc_set_function(0,5,0), f/f(0,00) returns 0.

By the way, I made a mistake in my initial question, it doesn’t work when setting input 0 as an input after having set it to an output (I used the wrong channel number). So we MUST have channel 0 as an output for digOutBank() to work.

To investigate further, I copy/pasted some functions from the LIB to the sample C program, renaming them so I could debug. I saw nothing special happening in the logic. The next step would be to check if the proper register values are set. But I think that should be done on Digi’s side, as it’s the library and I’m testing with a sample – no complex logic.

I guess I have to open a support ticket, right?

I suspect this line in _riosbc_set_block():

if (pin->function != RSB_FUNC_DIGOUT || pin->block2 > RSB_MAX_BLOCKS) {

If the code truly only sets output on pins in the block configured as outputs, the “pin->function != RSB_FUNC_DIGOUT” shouldn’t be necessary.

You could try running without that half of the if condition. I suspected that was the issue, but was confused by your earlier report that implied it would work with channel 0 set as an input after setting it as an output.

Feel free to open a support ticket about the bug. It will take some time for me to set up hardware in a manner that’s easy to replicate the problem, and then test the potential fix to verify that it works, and I can’t do that without a ticket submitted through Digi tech support.

And I see similar code in _riosbc_get_block(), called from digInBank(). So if the first I/O pin of a block doesn’t match the expected direction, it will fail.

Thank you Tom, I don’t know why I didn’t find that when looking at the code. I opened a support ticket for it (#344199).