I'm trying to use FreeMASTER for monitoring.
I want to use TXD1 on PS3, RXD1 on PS2.
So, I configure like follows:
in main.c file,
MODRR0_SCI1RR = 1; // serial port
DDRS_DDRS2 = 0;
DDRS_DDRS3 = 1;
SCI1BD = SCI_BAUDRATE;
SCI1CR2_TE = 1;
SCI1CR2_RE = 1;
in freemaster_cfg.h
#define FMSTR_SCI_BASE | 0x0710 |
void main(void)
{
initCPMU();
initGPIO();
initTIM();
initPMF();
initPTU();
initADC();
initSCI();
initGDU();
initInt();
FMSTR_Init();
EnableInterrupts;
AppInit();
AdcCalibration();
for(;;)
{
FMSTR_Poll();
AppStateMachine[appState]();
CheckFaults();
}
}
Anyone can help me?
已解决! 转到解答。
Hi Young-kyun,
Here are the answers:
A1:
The TIM channel 0 is internally connected as the commutation event signal into the PMF module.
This signal is used to control the buffered registers/bits on the PMF module (PMFOUTC, PMFOUTB, PMFCFG2[MSK]).
This allows the user to modify the register contents, but the changes in the PMF hardware will not take place until the commutation event signal becomes active.
If this feature is wanted/needed in the application, then it must be linked to channel 0.
However, the time base may run on a different timer channel. But in the end, the output compare event must come from channel 0.
For that matter, there is a bit called FOC0, in the TIM module, register CFORC.
This bit can be used to force an output compare event on timer channel 0.
A2:
I am not sure at this point. Since OC0 is internally connected to the PMF module, pin50 might be used as RXD0. However, the question is if OC0 will affect the state of external pin. Moreover, the PWM3 is also on pin50.
The Timer and PMF module has precedence over SCI0, so if TIM channel 0 or PWM3 are used, then RXD0 can cause conflict as it is 4th function of the pin50.
I assume you want to change OC0 channel to OC2 just because you want to use RXD0.
Pin#1 is dedicated to the LINPHY module. It cannot be changed nor re-routed by configuring MODRR register.
So for standalone usage of SCI0 on external pins you must disable LINPHY0 and set [S0L0RR2:S0L0RR0]=0b110 in the MODRR register.
Hope the information above is clear and understandable.
Regards,
iggi
Hi Young-kyun,
Regarding the SCI settings:
- the MODRR0 register is set OK;
- the Port S data direction register setup is redundant, since the Port S pins are automatically dedicated to the SCI, once the module is enabled.
- the baudrate and control register are usually set in the SCI initialization routine, so you can put it there for instance.
Maybe the Freemaster tool isn't correctly set. Here is an app note Freemaster Usage and serial driver implementation which should be of help. Check it out:
http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4752.pdf
Regards,
iggi
Hi iggi, application note AN4752 was not helpful but I can sure that configuration is not wrong via your reply, thanks for your advise.
Here is another question.
The Timer channel 0 is configured as OC0 for PMF(commutation event) module in reference code(MC9S12ZVML128_BLDC_Sensorless.c).
Q1. Is It impossible that setting Timer channel 2 as same function with OC for PMF?
I can't found any comment for changing OCx for PMF in datasheet.
Q2. Can I use PIN50 as RXD0 for SCI communication when I configured PIN1 for LIN?
I'm confusing Pin routing function. In datasheet LIN0 connection with SCI0.
that means user have to set S0L0RR when if user want to set the PIN1 for LIN.
However, It is no use. if IOC0_2 can't replace IOC0_0.
Am I wrong?
Hi Young-kyun,
Here are the answers:
A1:
The TIM channel 0 is internally connected as the commutation event signal into the PMF module.
This signal is used to control the buffered registers/bits on the PMF module (PMFOUTC, PMFOUTB, PMFCFG2[MSK]).
This allows the user to modify the register contents, but the changes in the PMF hardware will not take place until the commutation event signal becomes active.
If this feature is wanted/needed in the application, then it must be linked to channel 0.
However, the time base may run on a different timer channel. But in the end, the output compare event must come from channel 0.
For that matter, there is a bit called FOC0, in the TIM module, register CFORC.
This bit can be used to force an output compare event on timer channel 0.
A2:
I am not sure at this point. Since OC0 is internally connected to the PMF module, pin50 might be used as RXD0. However, the question is if OC0 will affect the state of external pin. Moreover, the PWM3 is also on pin50.
The Timer and PMF module has precedence over SCI0, so if TIM channel 0 or PWM3 are used, then RXD0 can cause conflict as it is 4th function of the pin50.
I assume you want to change OC0 channel to OC2 just because you want to use RXD0.
Pin#1 is dedicated to the LINPHY module. It cannot be changed nor re-routed by configuring MODRR register.
So for standalone usage of SCI0 on external pins you must disable LINPHY0 and set [S0L0RR2:S0L0RR0]=0b110 in the MODRR register.
Hope the information above is clear and understandable.
Regards,
iggi
Hi,
Here is the clarification of the pin#50 and TIM channel 0:
The Output Compare connection from Timer channel 0 to the PMF module, as a commutation event signal, is completely internal.
The output compare action can be disconnected from the port T0, setting bit OCPD0.
The timer channel 0 continues to operate internally, sets the flag, triggers the interrupt, and propagate the output compare action to the PMF.
So you can still use PT0 for the SCI0 RXD function. Just keep in mind that SCI0 can be internally linked to the LINPHY.
If you are not interested in using the LINPHY this way, you can use the SCI0 to interface with another module.
Regards,
iggi