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
Digital Output Write whole 16 bit word
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: Digital Output Write whole 16 bit word
Hi John,
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.
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.
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.resodad wrote:How can I send a 16 bit number to port B
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.
In the case that you are writing more than 1 bit,resodad wrote:Also, please clarify the use of "Exact Simultaneous Write" in the digital output block.
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.
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
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
- Attachments
-
- writeWord.mdl
- Simulink file to extract bits to write
- (55.04 KiB) Downloaded 1137 times
Who is online
Users browsing this forum: No registered users and 1 guest