It works now

The problem was with InitCPUTimers dunction (it was commented).
But some fact was found: If you flash with correct software first
 - Modbus is working. Then, if you comment InitCPUTimers function and
flash CPU again. The Modbus still working! But, if you turn off the power
Modbus will not work after power up. The reason is unknown
feature/Modbus
Oleg 4 weeks ago
parent a0fef5214d
commit 9feba6b8c9

@ -31,20 +31,20 @@ CPU::CPU():
void CPU::setup(DSP28335::CPUSetup& setup) void CPU::setup(DSP28335::CPUSetup& setup)
{ {
//adc.setup(); // adc.setup();
//
// //
scib.setup(setup.scib); scib.setup(setup.scib);
// //
// scic.setup(setup.scic); // scic.setup(setup.scic);
// InitCpuTimers();
// cpu_timers.setup(setup.timers); // cpu_timers.setup(setup.timers);
//
// epwm.setup(setup.epwm); // epwm.setup(setup.epwm);
//
// xintf.setup(setup.xintf); // xintf.setup(setup.xintf);
//
// period_measure.set_magic((Uint32)0); // period_measure.set_magic((Uint32)0);
// period_measure.reset(); // period_measure.reset();
// //

@ -46,24 +46,24 @@ struct CPUSetup
DSP28335::CPUTimersSetup timers; DSP28335::CPUTimersSetup timers;
DSP28335::EPWMSetup epwm; DSP28335::EPWMSetup epwm;
DSP28335::XINTFSetup xintf; DSP28335::XINTFSetup xintf;
// DSP28335::ECANASetup ecana; DSP28335::ECANASetup ecana;
// DSP28335::ECANBSetup ecanb; DSP28335::ECANBSetup ecanb;
// DSP28335::EQEP1Setup eqep1; DSP28335::EQEP1Setup eqep1;
// DSP28335::DiscreteOutputsSetup dout; DSP28335::DiscreteOutputsSetup dout;
// Uint16 period_sync; Uint16 period_sync;
// Uint16 startup_period; Uint16 startup_period;
CPUSetup(): CPUSetup():
scib(), scib(),
scic(), scic(),
timers(), timers(),
epwm(), epwm(),
xintf() xintf(),
// ecana(), ecana(),
// ecanb(), ecanb(),
// eqep1(), eqep1(),
// dout(), dout(),
// period_sync(0), period_sync(0),
// startup_period(0) startup_period(0)
{} {}
};//end SYSCoreSetup };//end SYSCoreSetup

@ -15,10 +15,10 @@ void DSP28335::CPU::get_hard_code_setup(DSP28335::CPUSetup& hsetup)
// At startup number synchronization pwm's periods // At startup number synchronization pwm's periods
// hsetup.startup_period = 20; hsetup.startup_period = 20;
// // // synchronization every pwm's cycle // synchronization every pwm's cycle
// hsetup.period_sync = 5; hsetup.period_sync = 5;
// //
@ -33,55 +33,55 @@ void DSP28335::CPU::get_hard_code_setup(DSP28335::CPUSetup& hsetup)
// //
// SCIC - internal interface // SCIC - internal interface
// //
// hsetup.scic.config.baudrate = SCIC_BAUDRATE_DEFAULT; hsetup.scic.config.baudrate = SCIC_BAUDRATE_DEFAULT;
// hsetup.scic.config.parity = SCIC_PARITY_DEFAULT; hsetup.scic.config.parity = SCIC_PARITY_DEFAULT;
// hsetup.scic.config.stopbits = SCIC_STOPBITS_DEFAULT; hsetup.scic.config.stopbits = SCIC_STOPBITS_DEFAULT;
// hsetup.scic.config.lenght = SCIC_LENGHT_DEFAULT; hsetup.scic.config.lenght = SCIC_LENGHT_DEFAULT;
// hsetup.scic.gpio_setup = SCIC_GPIO_SETUP_DEFAULT; hsetup.scic.gpio_setup = SCIC_GPIO_SETUP_DEFAULT;
// //
// CPU Timers // CPU Timers
// //
// hsetup.timers.frequency = 150.0; //150MHz hsetup.timers.frequency = 150.0; //150MHz
// hsetup.timers.period = 1000.0; //1000us hsetup.timers.period = 1000.0; //1000us
// //
// EPWM // EPWM
// //
// hsetup.epwm.parameters.fpwm = 500; //Hz hsetup.epwm.parameters.fpwm = 500; //Hz
// hsetup.epwm.parameters.pulse_sync = 1.0e-6; //s hsetup.epwm.parameters.pulse_sync = 1.0e-6; //s
// hsetup.epwm.parameters.pulse_adc_soc = 32.0e-6; //s hsetup.epwm.parameters.pulse_adc_soc = 32.0e-6; //s
// hsetup.epwm.parameters.adc_soc_offset = FP_ZERO; //relative hsetup.epwm.parameters.adc_soc_offset = FP_ZERO; //relative
// hsetup.epwm.parameters.adc_soc_quantity = 2; hsetup.epwm.parameters.adc_soc_quantity = 2;
// hsetup.epwm.gpio_setup = &DSP28335::GPIO::gpio_epwm_setup; hsetup.epwm.gpio_setup = &DSP28335::GPIO::gpio_epwm_setup;
// //
// XINTF // XINTF
// //
// hsetup.xintf.gpio_setup = &DSP28335::GPIO::gpio_xintf_16bit_setup; hsetup.xintf.gpio_setup = &DSP28335::GPIO::gpio_xintf_16bit_setup;
// //
// ECANA // ECANA
// //
// hsetup.ecana.gpio_setup = &DSP28335::GPIO::gpio_cana_setup; hsetup.ecana.gpio_setup = &DSP28335::GPIO::gpio_cana_setup;
// //
// ECANB // ECANB
// //
// hsetup.ecanb.gpio_setup = &DSP28335::GPIO::gpio_canb_setup; hsetup.ecanb.gpio_setup = &DSP28335::GPIO::gpio_canb_setup;
// //
// EQEP // EQEP
// //
// hsetup.eqep1.gpio_setup = &DSP28335::GPIO::gpio_eqep_setup; hsetup.eqep1.gpio_setup = &DSP28335::GPIO::gpio_eqep_setup;
// //
// Discrete Outputs // Discrete Outputs
// //
// hsetup.dout.gpio_setup = &DSP28335::GPIO::gpio_dicrete_outputs_setup; hsetup.dout.gpio_setup = &DSP28335::GPIO::gpio_dicrete_outputs_setup;
// //
}//end }//end

@ -28,27 +28,21 @@ interrupt void cpu_timer1_isr(void);
interrupt void canb_isr(void); interrupt void canb_isr(void);
interrupt void canb_box_isr(void); interrupt void canb_box_isr(void);
Periphery periphery; // Periphery periphery;
RUDRIVEFRAMEWORK::SinglePhaseSetup power_hw_setup;
RUDRIVEFRAMEWORK::SinglePhase power_hw((uint16_t*)0x4000);
WEINBUS::WeinbusSlave hmi(power_hw.crc);
MODBUSRTU::ModbusRTUTransceiverConfiguration modbus_port_configuration;
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
// DSP28335::SCISetup SCIbSetup; DSP28335::SCISetup SCIbSetup;
// DSP28335::SCIB scib(ScibRegs); DSP28335::SCIB scib(ScibRegs);
// DSP28335::MeasureTimeInterval interval_measure(CpuTimer2); DSP28335::MeasureTimeInterval interval_measure(CpuTimer2);
// // MODBUS RTU - PORT & HMI // MODBUS RTU - PORT & HMI
// MODBUSRTU::ModbusRTUTransceiverSetup modbus; MODBUSRTU::ModbusRTUTransceiverSetup modbus;
// MODBUSRTU::ModbusRTUCRC crc; MODBUSRTU::ModbusRTUCRC crc;
// MODBUSRTU::ModbusRTUTransceiver modbus_port(scib, interval_measure, crc); MODBUSRTU::ModbusRTUTransceiver modbus_port(scib, interval_measure, crc);
// WEINBUS::WeinbusSlave hmi(crc); WEINBUS::WeinbusSlave hmi(crc);
// MODBUSRTU::ModbusRTUTransceiverConfiguration modbus_port_configuration; MODBUSRTU::ModbusRTUTransceiverConfiguration modbus_port_configuration;
// Registers to testing HMI interface // Registers to testing HMI interface
@ -102,7 +96,7 @@ void main()
PieVectTable.ECAN1INTB = &canb_box_isr; PieVectTable.ECAN1INTB = &canb_box_isr;
EDIS; EDIS;
// InitCpuTimers(); InitCpuTimers();
ConfigCpuTimer(&CpuTimer0, 150, 1000); // 1ms ConfigCpuTimer(&CpuTimer0, 150, 1000); // 1ms
ConfigCpuTimer(&CpuTimer1, 150, 5000); // 5ms ConfigCpuTimer(&CpuTimer1, 150, 5000); // 5ms
@ -114,38 +108,34 @@ void main()
PieCtrlRegs.PIEIER9.bit.INTx7 = 1; // from 5 to 8 PieCtrlRegs.PIEIER9.bit.INTx7 = 1; // from 5 to 8
PieCtrlRegs.PIEIER9.bit.INTx8 = 1; PieCtrlRegs.PIEIER9.bit.INTx8 = 1;
periphery.config(); // periphery.config();
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
// SCIbSetup.config.baudrate = SCIB_BAUDRATE_DEFAULT; SCIbSetup.config.baudrate = SCIB_BAUDRATE_DEFAULT;
// SCIbSetup.config.parity = SCIB_PARITY_DEFAULT; SCIbSetup.config.parity = SCIB_PARITY_DEFAULT;
// SCIbSetup.config.stopbits = SCIB_STOPBITS_DEFAULT; SCIbSetup.config.stopbits = SCIB_STOPBITS_DEFAULT;
// SCIbSetup.config.lenght = SCIB_LENGHT_DEFAULT; SCIbSetup.config.lenght = SCIB_LENGHT_DEFAULT;
// SCIbSetup.gpio_setup = SCIB_GPIO_SETUP_DEFAULT; SCIbSetup.gpio_setup = SCIB_GPIO_SETUP_DEFAULT;
// modbus.gpio_re_de_setup = &DSP28335::GPIO::gpio_scib_re_de_setup; modbus.gpio_re_de_setup = &DSP28335::GPIO::gpio_scib_re_de_setup;
// modbus.gpio_driver_enable = &DSP28335::GPIO::gpio_scib_re_de_set; modbus.gpio_driver_enable = &DSP28335::GPIO::gpio_scib_re_de_set;
// modbus.gpio_receiver_enable = &DSP28335::GPIO::gpio_scib_re_de_clear; modbus.gpio_receiver_enable = &DSP28335::GPIO::gpio_scib_re_de_clear;
// scib.setup(SCIbSetup); scib.setup(SCIbSetup);
// interval_measure.set_magic((Uint32)0); interval_measure.set_magic((Uint32)0);
// interval_measure.reset(); interval_measure.reset();
// modbus_port.setup(modbus); modbus_port.setup(modbus);
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
// Enable global Interrupts and higher priority real-time debug events: // Enable global Interrupts and higher priority real-time debug events:
EINT; // Enable Global interrupt INTM EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM ERTM; // Enable Global realtime interrupt DBGM
periphery.updateVersionFPGA(); // periphery.updateVersionFPGA();
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
power_hw.get_hard_code_setup(power_hw_setup);
modify_hardware_setup(power_hw_setup);
power_hw.setup(power_hw_setup);
// MODBUS RTU // MODBUS RTU
// //
@ -157,17 +147,13 @@ void main()
// //
test_init_hmi_buffers(); test_init_hmi_buffers();
// modbus_port.configure(modbus_port_configuration); modbus_port.configure(modbus_port_configuration);
power_hw.modbus_port.configure(modbus_port_configuration);
clear_array((uint16_t *)hmi.rxStack, sizeof(hmi.rxStack)/sizeof(uint16_t)); clear_array((uint16_t *)hmi.rxStack, sizeof(hmi.rxStack)/sizeof(uint16_t));
clear_array((uint16_t *)hmi.txStack, sizeof(hmi.txStack)/sizeof(uint16_t)); clear_array((uint16_t *)hmi.txStack, sizeof(hmi.txStack)/sizeof(uint16_t));
// modbus_port.setRXBuffer((uint16_t*)hmi.rxStack, &hmi.rxLength); modbus_port.setRXBuffer((uint16_t*)hmi.rxStack, &hmi.rxLength);
// modbus_port.setTXBuffer((uint16_t*)hmi.txStack, &hmi.txLength); modbus_port.setTXBuffer((uint16_t*)hmi.txStack, &hmi.txLength);
power_hw.modbus_port.setRXBuffer((uint16_t*)hmi.rxStack, &hmi.rxLength);
power_hw.modbus_port.setTXBuffer((uint16_t*)hmi.txStack, &hmi.txLength);
// interval_measure.set_magic(19); // interval_measure.set_magic(19);
@ -188,19 +174,19 @@ void idle_loop()
{ {
infCounter++; infCounter++;
periphery.initExternalModbus(); // periphery.initExternalModbus();
// //
// MODBUS RTU HMI Service // MODBUS RTU HMI Service
// //
if(power_hw.modbus_port.compare_state(MODBUSRTU::BREAK)) if(modbus_port.compare_state(MODBUSRTU::BREAK))
{ {
power_hw.modbus_port.port_reset(); modbus_port.port_reset();
// //
} }
else else
{ {
power_hw.modbus_port.execute(); modbus_port.execute();
hmi.execute(); hmi.execute();
// //
}//if else }//if else
@ -213,7 +199,7 @@ void idle_loop()
interrupt void cpu_timer0_isr(void) interrupt void cpu_timer0_isr(void)
{ {
periphery.processDigitalOutput(); // periphery.processDigitalOutput();
PieCtrlRegs.PIEACK.all |= PIEACK_GROUP1; PieCtrlRegs.PIEACK.all |= PIEACK_GROUP1;
}//end }//end
@ -222,7 +208,7 @@ interrupt void cpu_timer0_isr(void)
interrupt void cpu_timer1_isr(){ interrupt void cpu_timer1_isr(){
CpuTimer1.InterruptCount++; CpuTimer1.InterruptCount++;
periphery.processDigitalInput(); // periphery.processDigitalInput();
} }

Loading…
Cancel
Save