FORUM TOPIC · READ ONLY

Digital Output Write whole 16 bit word

Digital Output Write whole 16 bit word

Forum : Advanced Simulink & RTW Questions

3 message(s) · archive en lecture seule

resodad
Hi Lubin,

How can I send a 16 bit number to port B? The block only accepts a boolean type.

Also, please clarify the use of "Exact Simultaneous Write" in the digital output block.

Thanks,

John
LubinKerhuel

Re: Digital Output Write whole 16 bit word

Hi John,


Citation : resodad
How can I send a 16 bit number to port B
In the blockset current version, this is a pain to do as you will have to decompose each bytes of your 16 bits number to feed a write block.

I should probably write another digital write function for this! Anyway, waiting for it, I would recommend to use the C call function block! The C function is quite straight here.


Citation : resodad
Also, please clarify the use of "Exact Simultaneous Write" in the digital output block.

In the case that you are writing more than 1 bit,

Actions when exact Simultaneous Write is checked:

- Read port value (on LATx register) and store the value in intermediate variable

- Modify the variable that depends on the values of the the simulink block input.

- Write the resulting variable back to LATx register.



Actions when exact Simultaneous Write is NOT checked:

- Modify the LATx register depending on the values of the simulink block input.

With this last method, bits are modified one by one thus bit change "is not simultaneous".



I hope I make it clear.
resodad

Re: Digital Output Write whole 16 bit word

Thanks Lubin,

I will try the C file block; I am sure it is better than what I did. I attach my simulink file anyway for those of us who are scared of C :?

Thanks for the clear explanation of simultaneous write.

Cheers,

John

Pièce jointe : writeWord.mdl