Hi there,
Just to let you know that i use S32k14x EAR SDK v08.6 for my coding
I have a module (Steering Lock). Which operates in a single wire communication protocol.
So, i am having trouble to figure out how to enable the communication between the module and my S32k146. The following are my queries .
1. Wiring Connection:
The above is the wiring details of the module. So the signal feedback wire (green), to which pin of the S32k146 i can connect this and how can i enable that signal in embeded terms based on the current.
2.Establishing Communication.
The fowwling is the lock vendor provided example. How can i acheive this
Example:
Host: controller
Slave:Steering lock
Lock: The host send out data:0xAAAA(Two-bytes) when the slave receives the
commends,it will extend the lock tongue to lock the steering lock and then reply its
current status.
Open: The host send out data: 0x5555(Two-bytes) When the slave receives the
commends,it will pull the lock tongue to open the steering lock and then reply its
current status.
If the slaves receives other commends,it will ignore it and will not do any things.
Can someone assist me with this. It would be a great help for me. Thanks in advance
Solved! Go to Solution.
Hi @akhilranga,
Unfortunately, there are no examples for one-wire communications for the S32K platform. You can implement this communication by connecting a GPIO from the MCU to your module, such as the following posts:
Also, using FlexCAN module there is no difference, but the CAN bit rate must be modified, and a different transceiver must be used, such as this one: Single-Wire Can Transceiver. Whichever protocol you choose is up to your implementation.
The scope of support for this public community is for NXP related devices. Please contact your vendor for documentation on which protocol to implement, or any related information.
Best regards,
Julián
Hi @akhilranga,
Unfortunately, there are no examples for one-wire communications for the S32K platform. You can implement this communication by connecting a GPIO from the MCU to your module, such as the following posts:
Also, using FlexCAN module there is no difference, but the CAN bit rate must be modified, and a different transceiver must be used, such as this one: Single-Wire Can Transceiver. Whichever protocol you choose is up to your implementation.
The scope of support for this public community is for NXP related devices. Please contact your vendor for documentation on which protocol to implement, or any related information.
Best regards,
Julián
Hi Julian,
i have developed a code for my above mentioned application but that is showing me some syntax errors. Can you please help me out with that.
/* Including needed modules to compile this module/procedure */
#include "S32K146.h"
#include "Cpu.h"
#include "clockMan1.h"
#include "pin_mux.h"
volatile int exit_code = 0;
/* User includes (#include below this line is not maintained by Processor Expert) */
#include <stdint.h>
#include <stdbool.h>
//#define LED_PORT PORTD
//#define GPIO_PORT PTD
//#define PCC_CLOCK PCC_PORTD_CLOCK
//#define LED1 15U
//#define LED2 16U
#define LOCK_COMM 7 //Output
#define Lock_Status 1 //Locked: 1, Unlocked 0
#define LOCK_COMMAND 0xAAAA //1010 1010 1010 1010
#define UNLOCK_COMMAND 0x5555 //0101 0101 0101 0101
void delay_ms(uint32_t milliseconds)
{
/* Delay function - do nothing for a number of cycles */
uint32_t ticks = milliseconds*(SystemCoreClock / 1000);
while(ticks--){}
}
void sendData( int dataLevel )
{
if (dataLevel == 1)
{
// Data 1:
// Turn on the LED
PTE->PCOR |= (1 << LOCK_COMM);
delay_ms(3);
// Turn off the LED
PTE->PSOR |= (1 << LOCK_COMM);
delay_ms(1); // Total 4ms delay
}
else if (dataLevel == 0)
{
// Data 0:
// Turn on the LED
PTE->PCOR |= (1 << LOCK_COMM);
delay_ms(1);
// Turn off the LED
PTE->PSOR |= (1 << LOCK_COMM);
delay_ms(3); // Total 4ms delay
}
//void initOneWirePin(void)
//{
// //configure GPIO pin PTE7 for command transmission
// PTE->PDDR &= ~COMMAND_PIN_MASK; // Set pin as input (pull-up)
//}
int main(void)
{
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of Processor Expert internal initialization. ***/
//initOneWirePin();
// Enable clock to PORT E (where the LOCK_COMM is connected)
PCC->PCCn[PCC_PORTE_INDEX] |= PCC_PCCn_CGC_MASK;
// Set pin as GPIO
PORTE->PCR[LOCK_COMM] |= PORT_PCR_MUX(1);
// Set pin as output
PTE->PDDR |= (1 << LOCK_COMM);
while (1)
{
int k = 0;
if (Lock_Status == 1){
// send 0xAAAA
delay_ms(5); //sync. head
for (int i = 0; i < 15; i++) {
//sendData(1);
//sendData(0);
sendData((LOCK_COMMAND >> i) & 0x01); // Send each bit of the lock command 1 or 0
}
delay_ms(4); //ACK
}
else if(Lock_Status == 0){
// send 0x5555
delay_ms(5); //sync. head
for (int i = 0; i < 15; i++) {
//sendData(0);
//sendData(1);
sendData((UNLOCK_COMMAND >> i) & 0x01); // Send each bit of the unlock command 1 or 0
}
delay_ms(4); //ACK
}
delay_ms(200);
if( k += 10)
{
break;
}
}
/*** Don't write any code pass this line, or it will be deleted during code generation. ***/
/*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/
#ifdef PEX_RTOS_START
PEX_RTOS_START(); /* Startup of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of RTOS startup code. ***/
/*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/
for(;;) {
if(exit_code != 0) {
break;
}
}
return exit_code;
/*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/
}/*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/
/* END main */
/*!
** @}
*/
/*
** ###################################################################
**
** This file was created by Processor Expert 10.1 [05.21]
** for the Freescale S32K series of microcontrollers.
**
** ###################################################################
*/
the below screenshot shows the errors. So, tell me what is that i am doing wrong.
Help me validate my approach.
With your input i was able to close all the issues and started testing the code. But while testing i noticed that my code was not passing throught the delay_ms function. It is completly skipping this dealy_ms function which was called in the senddata function and skipping on to the next line of the code. can you please help me identify what might be the issue. Please cherck out the code as mentioned in the thread.
Hi @akhilranga,
It seems you are missing a closing brace in your sendData function:
Best regards,
Julián