Hi,
I am having problems with the SCI and Flextimer modules of a S08PA4 (16Pin). The system clock is set to 20MHz.
I just need to transmit so I deactivated the Rx part. The transmission is configured as follows:
8 Bit, Boud rate is set to156kbps, No parity and no interrupts activated (I use a polling mechanism)
void InitSCI0Module_v(void)
{
SCI0_BDH = 0x00;
SCI0_BDL = 0x08; /*Set BR to 156k bps */
SCI0_C1 = 0x00; /* RxD and TxD use separate pins, 8 Bits, Parity disabled, SCI clocks continue to run in wait mode, */
SCI0_C2 = 0x08; /* Receiver is off,Transmitter is on, No iterrupt but polling */
SCI0_C3 = 0x00; /* Transmit data not inverted */
}
void TX_Data_v(void)
{ /* Transmit only if buffer is empty */
if(TRUE == TX_BUFFER_EMPTY)
{/* Load byte */
SCI0_D = Data_u8; /* Data_u8 updated in another function */
}
}
#define TRUE 0x01
#define Sys_D_BIT7 0x80
#define TX_BUFFER_EMPTY ((SCI0_S1 & Sys_D_BIT7) == Sys_D_BIT7) /* Transmit Data Register Empty Flag */
With a Debugger I can see that when I call the function TX_Data() the transmit buffer is empty (flag is set) and that after loading Data_u8 in the A register the assembler command STA SCI0_D is executed but the register SCI0_D register does not change its value. Am I forgeting something? Does anyone have an idea of what is not correct?
Now the next topic is with the Flextimer.
I need to configure the Channel 0 as input capture in the pin PTA2. Here is how I initialize the module.
void InitPinOptions_v(void)
{
SYS_SOPT1 = 0x2C; /* FTM0 on PTA2 and PTA 3, PTA4/ACMPO/BKGD/MS as BKGD function */
SYS_SOPT2 = 0x00; /* Just as default */
SYS_SOPT3 = 0x00; /* Just as default */
}
void InitTimerModule_v(void)
{
FTM0_SC = 0x08; /* Over flow interrupt disabled, Counting up, System clock, no clock divider (20MHz) */
FTM0_MOD = ZERO_U16; /* Free running configuration */
FTM0_C0SC = ; /* Interrupt enabled, input capture for rising edge */
FTM0_C1SC = ZERO_U8; /* Channel 1 not used */
}
The interrupt function is correctly mapped (FFDE:FFDF) and global interrupts are activated.
I just connect a square signal to the pin PTA2 with an appropiate frequency and amplitude, but the mC does not jump to the interrupt function.
Again my questions. Am I forgeting something? Does anyone have an idea of what is not correct?
Best regards,
Omar
Nachricht geändert durch Omar Ayala. Hi, I just made a correction: When the transmit buffer is empty the flag is set and not cleared as I posted in my original description.
Nachricht geändert durch Omar Ayala: Hi, another correction. To get the 156 Kbps the SCIo_BDL must be loaded with SCI0_BDL = 0x08 and not 0x04. I just made a small test before with the Value 0x04 and forgot to correct the comment. The speed that I want to configure is 156Kbps.
Nachricht geändert durch Omar Ayala: Hi I just added some of the defines that I use.
Hi,
well I found the error :smileyhappy:. It was the ADC that was wrongly configured. I misunderstood the description of the ADC_APCTL1 register :smileyconfused:. So I had wrongly deactivated all general purpose ports with the exception of one:smileyblush:. Now everything works fine as I wanted.
Oh by the way I could not see that the SCI0_D register changed its value because reading reads the read-only Data register (Rx Data register). So if one wants to control whether the information to transmit is correct or not, one would need to configure the SCI Module in LOOP mode.
@Vicente and all that took a look to my case: Thank you for your support.
Hi Vicente,
Well I want to use alt 2 for FTM and SCI. That is why I set the options register like this:
void InitPinOptions_v(void)
{
SYS_SOPT1 = 0x2C; /* SCI0 on PTB0 and PTB1, FTM1 on PTB4 and PTB5, FTM0 on PTA2 and PTA 3, PTA4 as BKGD function and PTA5 as RESET*/
SYS_SOPT2 = 0x00; /* Just as default */
SYS_SOPT3 = 0x00; /* Just as default */
}
In general the pin funtionality that I want to have is like the highlighted one. I do not need to receive anything, for that reason I configured the PTB0 as output (for debugging). But since the SCI0 is not working I could activate the pin as Rx.
I activate the modules in this sequence ADC -> FTM -> SCI -> PIM using the following function
void InitMC_v(void)
{
/************************************/
/* Clock, Watchdog Module */
/************************************/
InitCLKModule_v();
/*****************/
/* Pin mapping */
/*****************/
InitPinOptions_v();
/*******************************/
/* ADC Module */
/*******************************/
/* Adc module related uC specific initialization */
InitAdcModule_v();
/*******************************/
/* Timer Module */
/*******************************/
/* Timer module related uC specific initialization */
InitTimerModule_v();
/*******************************/
/* SCI0 Module */
/*******************************/
/* SCI0 module related uC specific initialization */
InitSCI0Module_v();
/*******************************/
/* PIM Module */
/*******************************/
/* PIM module related uC specific initialization */
InitPIMModule_v();
}
Am I doing something wrong?
Hi Omar
Please check the attached project, this is a CW 10.6 sample code that set the SCI on the TWR-PT60 and just set the letter 'a' through the SCI2 also this code set the FTM2 as PWM and the FTM1 as input capture.
Please remember TRIM the clock if you are using the internal clock,in order to about SCI communication problem due the baud rate.
Have a great day,
Vicente
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Vicente,
thank you for your help.
Well, I checked your files and I am doing basically the same. Some differences exist like:
1. The PA4 that I am using is a 16 Pin one with only one SCI module (SCI0).
2. The flex timer we use is mapped to pins PTA2 and PTA3 (as mentioned before). Could you check if by doing this system interconection you still do not have problems transmitting?
3. I trim the µC with Cyclone Pro, so I have another trim initialization as the the one in your files. This should not make a difference since the trim values are loaded automatically during initialization. (See a portion of the Datasheet below)
I still have problems with the SCI and Flextimer. SCI0 does not work at all and Flextimer 0 works to 50% (only channel 0) if I use the default system interconnection.
I would appreciate if you could give me more hints.
Best Regards,
Omar
Hi Omar
The PTA3 and PTA2 are the pins for the SCI0 (this is the alt 3 ) but also are the FTM0CH0 and FTM0CH1,
because of this you can not use the SCI and the FTM on the same pins, on this case the PTA2 and PTA3, please try to use the PTA1 and PTA0 for the FTM function
Have a great day,
Vicente
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------