I cannot seem to get the Serial_LDD module to receive any characters.
What bothers me is that I've set a breakpoint in the Event.c onBlockReceive interrupt, but the program NEVER reaches it. I have tried arduino console, putty, python for sending serial characters, checked the serial port a hundred times, doesn't seem related to the computer.
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization. ***/
/* Write your code here */
/* For example: for(;;) { } */
set_serial_state(FALSE);
uint8_t data[10];
AS1_ReceiveBlock(AS1_DeviceData, data, 1);
for(;;)
{
if(get_serial_state())
{
// Send it back
AS1_SendBlock(AS1_DeviceData, data, 1);
set_serial_state(FALSE);
}
}
#ifndef SOURCES_FUNCTIONS_H_
#define SOURCES_FUNCTIONS_H_
#include "PE_Types.h"
extern bool serial_rx_state;
void set_serial_state(bool state);
bool get_serial_state();
#endif /* SOURCES_FUNCTIONS_H_ */
bool serial_rx_state;
void set_serial_state(bool state)
{
serial_rx_state = state;
}
bool get_serial_state()
{
return serial_rx_state;
}
void AS1_OnBlockReceived(LDD_TUserData *UserDataPtr)
{
/* Write your code here ... */
set_serial_state(TRUE);
}
If somebody can hint me why it's not working, I would appreciate it because I'm completely stuck. I'm just stunned that this simple code won't simply work. I'm using KDS 3.00 and KL26Z
BTW the documentation of the serial_ldd component seems out of date, it is referring to a ProcessorExpert.c file, but I cannot find this file anywhere in the hierarchy.
PS : No block code in this online editor ??
EDIT : I cannot even send characters now
* Write your code here */
/* For example: for(;;) { } */
set_serial_state(FALSE);
uint8_t data[10];
AS1_ReceiveBlock(AS1_DeviceData, data, 1);
uint32_t i = 0;
while(1)
{
if(i >= 10000)
{
data[0] = "o";
data[1] = "k";
AS1_SendBlock(AS1_DeviceData, data, 2);
i = 0;
}
else
i++;
}
I receive strictly nothing. Also checked speed (9600 bauds), same on both sides. This is starting to be very frustrating
Solved! Go to Solution.
it is done in PE_low_level_init
Is there anything else to activate transmitter and emitter ?
EDIT :
I forgot to check transmitter and emitter pins, for using KL26Z usb serial I think they were wrong by default.
I think the following pins are right :
Receiver : TSI0_CH2/PTA1/UART0_RX/TPM2_CH0
Transmitter : TSI0_CH3/PTA2/UART0_TX/TPM2_CH1
I'll edit once I tested that
Is initialization done by PE_low_level_init() or by separate AS1_Init() ?
Do you enable receiver and transmitter in Processor expert?
it is done in PE_low_level_init
Is there anything else to activate transmitter and emitter ?
EDIT :
I forgot to check transmitter and emitter pins, for using KL26Z usb serial I think they were wrong by default.
I think the following pins are right :
Receiver : TSI0_CH2/PTA1/UART0_RX/TPM2_CH0
Transmitter : TSI0_CH3/PTA2/UART0_TX/TPM2_CH1
I'll edit once I tested that
OK now I can send characters appropriately. I also solved my initial issue, the mcu never seemed to receive the incoming characters because I am using the MULT2B sensor shield that hosts a bluetooth module. This module will capture any incoming data on the openSDA port, that will not be forwarded to the MCU. And thus the MCU will never see this data if connected by USB cable. Once I removed the shield, the MCU behaved as expected.