Hello, I’m trying to write a simple code to test SCI communication between two 8bit mcus, specifically a MC9S08SH8 and a MC9S08AC16, I’ve been able to verify that the transmitter is transmitting and that the receiver is realizing that there's something trying to be sent, but the SCIS1_FE flag always gets set on the receiver end.
Right now I’m trying to send a full 0xff byte, but I’ve tried with a lot of arbitrary combinations of 0's and 1's and the result is the same.
Some info that might be important:
Transmission is ocurring at 62,5 bauds, or 8MHz/(16*8000)
Both mcus are running at 8MHz but the receiver is using a crystal while the transmitter is using internal clock.
Watchdogs are disabled.
Devices were initialized by processor expert.
there are "witness" LEDS on the transmission wire and a couple more on some GPIO pins to indicate some things, mostly framing error, transmission on going and waiting.
Transmission is done by polling while reception is done by interrupts.
Interrupt vector are declared on a separate header.
Code for the transmitter:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "PTC.h"
#include "COPFree.h"
#include "SCI.h"
/* Include shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
/* User includes (#include below this line is not maintained by Processor Expert) */
#define L_R PTCD_PTCD0
#define L_Y PTCD_PTCD1
#define TRANSMIT_READY SCIS1_TDRE
#define TRANSMIT_FINISH SCIS1_TC
#define TRANSMIT_ENABLE SCIC2_TE
void tx_s(unsigned char s[]);
void tx_c(unsigned char cr);
unsigned char string[17] = {
0x01,
0x02,
0x04,
0x08,
0x10,
0x20,
0x40,
0x80,
0x11,
0x22,
0x44,
0x88,
0x81,
0x42,
0x24,
0x18,
'\0'
};
unsigned long j=0;
void main(void)
{
/* Write your local variable definition here */
/*** 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(;;) { } */
/*** 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!!! ***/
PTBDD_PTBDD7=0;
PTBDD_PTBDD5=1;
for(;;){
__asm NOP;
if(PTBD_PTBD7 == 1){
PTBD_PTBD5=0;
L_Y=1;
L_R=0;
TRANSMIT_ENABLE=1;
//tx_s( string );
SCIC2_SBK=1;
tx_c(0xff);
TRANSMIT_ENABLE=0;
}
PTBD_PTBD5=1;
L_Y=0;
L_R=1;
for(j=0;j<50000;j++){
__asm NOP;
}
}
/*** 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.3 [05.09]
** for the Freescale HCS08 series of microcontrollers.
**
** ###################################################################
*/
void tx_c(unsigned char cr){
(void)SCIS1;
SCID=cr;
}
void tx_s(unsigned char s[]){
unsigned int i=0;
unsigned long l=0;
while( s[i] != '\0' ){
if( (TRANSMIT_READY == 1) &&
(TRANSMIT_FINISH ==1) ){
tx_c(s[i]);
}
else{
//continue;
}
i++;
}
//for(l=0;l<20000;l++){
// __asm NOP;
//}
}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Code for the receiver:
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/* ###################################################################
** Filename : main.c
** Project : RXPrueba
** Processor : MC9S08AC16CFD
** Version : Driver 01.12
** Compiler : CodeWarrior HCS08 C Compiler
** Date/Time : 2019-09-29, 19:16, # CodeGen: 0
** Abstract :
** Main module.
** This module contains user's application code.
** Settings :
** Contents :
** No public methods
**
** ###################################################################*/
/*!
** @file main.c
** @version 01.12
** @brief
** Main module.
** This module contains user's application code.
*/
/*!
** @addtogroup main_module main module documentation
** @{
*/
/* MODULE main */
/* Including needed modules to compile this module/procedure */
#include "Cpu.h"
#include "Events.h"
#include "COPFree.h"
#include "PTE.h"
#include "SCI2.h"
/* Include shared modules, which are used for whole project */
#include "PE_Types.h"
#include "PE_Error.h"
#include "PE_Const.h"
#include "IO_Map.h"
/* User includes (#include below this line is not maintained by Processor Expert) */
#define RECIVE_READY SCI2S1_RDRF
#define RECIEVE_ENABLE SCI2C2_RE
#define Enable_interrupts __asm CLI
#define Disable_interrupts __asm SEI
void rx(void);
void err(void);
void main(void)
{
/* Write your local variable definition here */
/*** 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(;;) { } */
/*** 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!!! ***/
__asm NOP;
PTADD_PTADD0=1;
PTADD_PTADD1=0;
PTBDD_PTBDD0=1;
Enable_interrupts;
for(;;){
PTBD_PTBD0=0;
if(PTAD_PTAD1 == 1){
RECIEVE_ENABLE=1;
PTAD_PTAD0=1;
}
__asm NOP;
}
/*** 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.3 [05.09]
** for the Freescale HCS08 series of microcontrollers.
**
** ###################################################################
*/
void rx(void){
(void)SCI2S1;
PTED = SCI2D;
__asm NOP;
RECIEVE_ENABLE=0;
PTAD_PTAD0=0;
PTBD_PTBD0=0;
}
void err(void){
(void)SCI2S1;
PTED = SCI2D;
RECIEVE_ENABLE=0;
PTAD_PTAD0=0;
PTBD_PTBD0=1;
}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------