How to set Douts in firmware

Programmable 6-channel router and data logger for CAN and CAN FD with I/O and optional Ethernet interface
Post Reply
technick100
Posts: 2
Joined: Mon 15. Apr 2024, 07:12

How to set Douts in firmware

Post by technick100 » Mon 15. Apr 2024, 07:27

Could you please hel us.

We have PCAN-Router Pro FD.
Bootloader version: 2.0.11
Hardware Version 5
FPGA ver: 10

We downloaded the latest version of the developer's package and checked an example "08_HW_IO".

The problem is next....if we run this code

Code: Select all

HWResult_t  HW_SetDOUT ( uint32_t  *buffer)
{
   if ( buffer == NULL)
	 { return HW_ERR_ILLPARAMVAL;}
   
   FPGA->SYS_DOUT_WR = buffer[0];

   return HW_ERR_OK;
}

uint32_t  tmp32 = 0xFFFF (or 0xFF);
// set DOUTs, all bits used
HW_SetDOUT ( &tmp32);
we receive 12 volts only on the first output, the other three outputs show 0 volts. How to set "logic 1" on another outputs?
0xFF is 0b11111111

we tried to use 0x0F, also no any effects.

M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: GPIO not work properly. Please Help!!!

Post by M.Heidemann » Mon 15. Apr 2024, 09:12

Hello,

Please have a look at /inc/hardware.c

Code: Select all


//! @brief
//! Set digital outputs. Each bit will represent a digital pin.
//! 
//! @param		buffer		Buffer for DOUT-value
//!
//! @return		one error of HW_ERR_...
HWResult_t  HW_SetDOUT ( uint32_t  *buffer);
As well as example "08_HW_IO", /src/main.c

Code: Select all


					// catch ID 334h to control DOUTs
					if ( RxMsg.id == 0x334  &&  RxMsg.msgtype == CAN_MSGTYPE_STANDARD)
					{
                  uint32_t  tmp32;


                  tmp32 = RxMsg.data8[0];

						// set DOUTs, all bits used
						HW_SetDOUT ( &tmp32);
						break;
					}


					// catch ID 55Ah to send analog value from AIN
					if ( RxMsg.id == 0x55A  &&  RxMsg.msgtype == CAN_MSGTYPE_STANDARD)
					{
                  uint32_t  tmp32;
Make sure you the example works as expected on your device, if so, you can proceed with your own implementation based on that.

Best Regards

Marvin
---
Marvin Heidemann
PEAK-Support Team

technick100
Posts: 2
Joined: Mon 15. Apr 2024, 07:12

Re: GPIO not work properly. Please Help!!!

Post by technick100 » Mon 15. Apr 2024, 09:24

Hello, Marvin

Thank you for your answer. I have read your response and I'll ask it in another way.

Our code and code from example almost same, my question is:
what value should be set inside RxMsg.data8[0] to get "logic 1" at all four digital outputs?

Code: Select all

uint32_t  tmp32;

tmp32 = RxMsg.data8[0];

// set DOUTs, all bits used
HW_SetDOUT ( &tmp32);


M.Heidemann
Sales & Support
Sales & Support
Posts: 1083
Joined: Fri 20. Sep 2019, 13:31

Re: GPIO not work properly. Please Help!!!

Post by M.Heidemann » Mon 15. Apr 2024, 10:33

Hello,

Given we have 4 DOUTS and a 32bit buffer,
that means youll will need at least 4 bytes -> 0xffh 0xffh 0xffh 0xffh

Best Regards

MArvin
---
Marvin Heidemann
PEAK-Support Team

Post Reply