Page 1 of 1

Dout and Din pins on PCAN-RS-232

Posted: Tue 15. Mar 2016, 14:51
by AcmarAuto
Hello,
i would like and example in 'C' code to use :
1.pin 5 Dout (output) with HW_SetDOUT ?
2.pin 6 Din (input) with HW_GetDIN ?
on PCAN-RS232?
Regards

Re: Dout and Din pins on PCAN-RS-232

Posted: Wed 16. Mar 2016, 11:04
by PEAK-Support
please see Header file on product Disk

Code: Select all

//! @brief
//! Read digital inputs. Each bit will represent a digital pin.
//! Not available on PCAN-Router Pro
//!
//! @param		buffer		Buffer for DIN-value
//!
//! @return		one error of HW_ERR_...
HWStatus_t  HW_GetDIN ( u32_t  *buffer);


//! @brief
//! Set digital outputs. Each bit will represent a digital pin.
//! Only available on PCAN-RS-232.
//! 
//! @param		buffer		Buffer for DOUT-value
//!
//! @return		one error of HW_ERR_...
HWStatus_t  HW_SetDOUT ( u32_t  *buffer);
Here a simple code part how to use it:

#read the input:

Code: Select all

HW_GetDIN (&inbuf);
if ((inbuf&1) == 1) // Din1 = hi ? -- means PIN 6 of Module
{...}
#set the output:

Code: Select all

outbuf = 1;
HW_SetDOUT (&outbuf); // Dout-1, low-active: 0=open, 1=GND !!!  -- means PIN 5 of Module
We will create a #define for the DIO in the next release of the Firmware to keep it more simple!

Re: Dout and Din pins on PCAN-RS-232

Posted: Fri 18. Mar 2016, 15:43
by PEAK-Support
We now have add a sample projekt for the Digital I/O to the product information.
Please see sample 8 on the Product DVD in the section Develop - Microcontroller hardware - PCAN-RS232 - Examples.

main.c