The present invention relates to a switch on/off control method for being performed in a switch circuit that is provided with: a DMA controller for periodically DMA-transferring a plurality of pieces of transfer data in a memory; and a switch that is controlled to be turned on/off based on the transfer data from the DMA controller, and relates to the switch circuit.
In recent years, variety of switch circuits, called IPDs (Intelligent Power Devices), have been commercialized. IPDs have, for example, a function to protect a built-in switch from an overcurrent, a function to sense an electric current flowing through the switch, and the like. By controlling such an IPD to be turned on/off with a PWM signal to switch a power-supply voltage, electric power control is performed easily and safely on a load that is connected to an electric power supply via the IPD.
A PWM signal for use in PWM control may be generated, without intervention of software, based on, for example, a comparison result between an error voltage between a feedback control amount (output value) and a target value, and a voltage of a saw-tooth wave or a triangle wave. On the other hand, a PWM signal may be generated with software control based on, for example, a timer interrupt.
If a PWM signal is generated with software control, a processing load of a CPU will increase due to rising of the PWM signal changing from OFF to ON, or falling of the PWM signal changing from ON to OFF. Furthermore, when the CPU is in an interrupt-disabled state for example, timer interrupt processing may delay, and an error may occur in duty of the PWM signal.
In order to solve the problems, “Multiple PWM generation with RL78/G13 DMA”, published on Feb. 29, 2012, by the Renesas Electronics Corporation (the “Renesas Reference”, see http://documentation.renesas.com/doc/products/mpumcu/apn/rl78/r01an1023jj0100#rl78g13.pdp discloses a method for outputting a PWM signal in synchronization with DMA transfer from an I/O port, using a configuration in which the DMA transfer is periodically performed to the I/O port from a PWM reference table in which a plurality of pieces of I/O data are written that correspond to on/off of the PWM signal. According to the method disclosed in the “Renesas Reference”, since a CPU only needs to update the PWM reference table and periodically set and start the DMA transfer, a processing load of the CPU is reduced.
Meanwhile, some IPDs such as “SPOC®” of Infineon AG include a switch that is controlled to be turned on/off based on a command given via a serial communication interface. SPOC is provided with the communication interface that conforms to the communication standard called “SPI®”. Infineon AG introduces, in “How to drive loads with PWM over the SPI bus: Introduction”, published online on 2013 Oct. 16, by Infineon AG Technologies (the “Infineon Reference,” see http://www.youtube.com/watch?v=obFP7GDJDus), an example in which series of commands for realizing PWM control using SPOC® are periodically given to the SPOC®. Specifically, a method called “raster method” is used to give commands for one period that are necessary for PWM control to the SPOC® one by one at predetermined time intervals. In this case, the DMA transfer technique disclosed in the Renesas Reference is applied.
However, according to the technique disclosed in the Infineon Reference, since the CPU needs to write the commands for one period for use in PWM control to the memory, and then to set and start DMA transfer, a processing load of generating the commands for one period and writing the generated commands to the memory is still not light.
The present invention was made in view of such circumstances, and it is an object thereof to realize a switch on/off control method and a switch circuit that can reduce a processing load when controlling on/off of a switch whose various operations are controlled based on control data.
According to the present invention, a switch on/off control method for being performed in a switch circuit that is provided with: a DMA controller for DMA-transferring all of a plurality of pieces of transfer data written in a predetermined region of a memory in a predetermined period; and a switch that is controlled to be turned on/off based on the transfer data from the DMA controller is such that the transfer data is ON data for use in controlling the switch to be turned on, OFF data for use in controlling the switch to be turned off, or third data for use other than in controlling the switch to be turned on/off, the third data is written in advance in the entire predetermined region, transfer source addresses from which the transfer data is DMA-transferred to the switch at a phase at which the switch is to be controlled to be turned on and a phase at which the switch is to be controlled to be turned off are respectively calculated, the phases being included in the predetermined period, and the ON data and the OFF data are respectively written over the third data that was written at the calculated transfer source addresses.
The switch on/off control method according to the present invention may be such that the third data is written over a content of the transfer source address at which the ON data (or OFF data) was written, the transfer source address from which the transfer data is DMA-transferred to the switch is updated at the phase at which the switch is to be controlled to be turned on (or phase at which the switch is to be controlled to be turned off), and the ON data (or OFF data) is written over the third data that was written at the updated transfer source address.
The switch on/off control method according to the present invention may be such that a storage section is prepared, the transfer source address at which the ON data (or OFF data) was written is stored in the storage section, the transfer source address stored in the storage section, and the updated transfer source address are compared with each other, and if a result of the comparison shows that the transfer source addresses match each other, overwriting of the third data and overwriting of the ON data (or OFF data) are disabled.
The switch on/off control method according to the present invention may be such that the ON data (or OFF data) is written over the third data that was written at a calculated or updated transfer source address, and an address distanced from the calculated or updated transfer source address.
The switch on/off control method according to the present invention may be such that a second storage section is prepared, the switch circuit is provided with a plurality of the switches, the plurality of switches are configured to be individually controlled to be turned on and off by one of the pieces of transfer data from the DMA controller, a range of phases at which none of the switches is controlled to be turned on/off is set in advance in the predetermined period, a range of transfer source addresses from which the transfer data is DMA-transferred to the switch within the set range of phases is stored in the second storage section, another piece of third data is written over the third data that was written at a suitable address within the range of transfer source addresses that was stored in the second storage section.
The switch on/off control method according to the present invention may be such that transfer source addresses from which the transfer data is DMA-transferred to the switch at the phase at which the switch is to be controlled to be turned on, and the phase at which the switch is to be controlled to be turned off are respectively calculated from odd-numbered (or even-numbered) addresses in the predetermined region, and another piece of third data is written over the third data that was written at a suitable address of even-numbered (or odd-numbered) addresses in the predetermined region.
The switch on/off control method according to the present invention may be such that a boundary between pieces of transfer data that are to be DMA-transferred sequentially in the predetermined region is set in advance, and while a piece of transfer data located on a front side (or rear side) of the boundary is DMA-transferred, another piece of transfer data is written over a suitable piece of transfer data on the rear side (or front side).
According to the present invention, a switch circuit includes: a DMA controller for DMA transferring all of a plurality of pieces of transfer data written in a predetermined region of a memory in a predetermined period, and a switch that is controlled to be turned on/off based on the transfer data from the DMA controller, wherein the transfer data is ON data for use in controlling the switch to be turned on, OFF data for use in controlling the switch to be turned off, or third data for use other than in controlling the switch to be turned on/off, and the switch circuit further includes: writing means for writing the third data in the entire predetermined region; calculating means for calculating transfer source addresses from which the transfer data is DMA-transferred to the switch at a phase at which the switch is to be controlled to be turned on and a phase at which the switch is to be controlled to be turned off, the phases being included in the predetermined period; and overwriting means for respectively writing the ON data and OFF data over the third data that was written at the transfer source addresses calculated by the calculating means.
The switch circuit according to the present invention further includes: second overwriting means for writing the third data over a content of the transfer source address at which the ON data (or OFF data) was written; and updating means for updating the transfer source address from which the transfer data is DMA-transferred to the switch at the phase at which the switch is to be controlled to be turned on (or a phase at which the switch is to be controlled to be turned off), wherein the overwriting means is configured to write the ON data (or OFF data) over the third data that was written at the transfer source address updated by the updating means.
The switch circuit according to the present invention further includes: storing means for storing the transfer source address at which the ON data (or OFF data) was written; comparing means for comparing the transfer source address stored by the storing means and the transfer source address updated by the updating means; and disabling means for disabling overwriting of the third data and overwriting of the ON data (or OFF data) if a result of the comparison by the comparing means shows that the transfer source addresses match each other.
The switch circuit according to the present invention may be such that the overwriting means is configured to write the ON data (of OFF data) over third data that was written at the transfer source address that was calculated by the calculating means or updated by the updating means, and an address distanced from the calculated or updated transfer source address.
The switch circuit according to the present invention may be such that the switch circuit is provided with a plurality of the switches, the plurality of switches are configured to be individually controlled to be turned on and off by one of the pieces of transfer data from the DMA controller, and a range of phases at which none of the switches is controlled to be turned on/off is set in advance in the predetermined period, the switch circuit further includes: second storing means for storing a range of transfer source addresses from which the transfer data is DMA-transferred to the switch within the set range of phases; and third overwriting means for writing another piece of third data over the third data that was written at a suitable address within the range of transfer source addresses that was stored by the second storing means.
The switch circuit according to the present invention further includes: second calculating means for calculating transfer source addresses from which the transfer data is DMA-transferred to the switch at the phase at which the switch is to be controlled to be turned on and the phase at which the switch is to be controlled to be turned off, from odd-numbered (or even-numbered) addresses in the predetermined region; and fourth overwriting means for writing another piece of third data over the third data that was written at a suitable address of even-numbered (or odd-numbered) addresses in the predetermined region.
The switch circuit according to the present invention may be such that a boundary between pieces of transfer data that are to be DMA-transferred sequentially in the predetermined region is set in advance, and the switch circuit further comprises fifth overwriting means for writing, while a piece of transfer data located on a front side (or rear side) of the boundary is DMA-transferred, another piece of transfer data over a suitable piece of transfer data on the rear side (or front side).
According to the present invention, all of a plurality of pieces of transfer data in a predetermined region of the memory are DMA-transferred in a predetermined period, and the pieces of DMA-transferred transfer data are given to the switch to control the switch to be turned on/off periodically. The transfer data is ON data/OFF data for controlling the switch to be turned on/off, or third data that is irrelevant to the on/off control of the switch. Among the transfer data, the third data was written in advance in the entire predetermined region. For example, when phases at which the switch is to be controlled to be turned on and off in the predetermined period are obtained, or when a target duty is given so that phases at which the switch is controlled to be turned on and off are calculated, transfer source addresses from which the transfer data is DMA-transferred to the switch at the obtained or calculated phases are calculated, and ON data and OFF data are written over the third data that was written in advance at the calculated transfer source addresses.
In short, fixed control data irrelevant to the on/off control of the switch was uniformly written in the entire predetermined region of the memory, ON data and OFF data are written over contents of the transfer source addresses of the memory that correspond to the phases at which the switch is to be controlled to be turned on and off, and then all the pieces of transfer data in the predetermined region of the memory are sequentially DMA-transferred. Therefore, the switch is controlled to be turned on/off at the phases that correspond to the transfer source addresses at which the ON data and the OFF data were written.
According to the present invention, prior to updating the phases at which the switch is controlled to be turned on/off, the third data is written over the content of the non-updated transfer source address at which ON data and/or OFF data was written. Then, the transfer source address from which the transfer data is DMA-transferred to the switch is updated at a new phase at which the switch is to be controlled to be turned on and/or off. Then, when the transfer source address for ON control of the switch is updated, ON data is written over the content of the updated transfer source address, and when the transfer source address for OFF control of the switch is updated, OFF data is written over the content of the updated transfer source address.
In short, when the transfer source address at which ON data and/or OFF data is to be written is updated, third data is written over the content of the non-updated transfer source address, the transfer source address is updated in response to the overwriting, and ON data and/or OFF data is written over the content of the updated transfer source address, making it easy to update the phase at which the switch is to be controlled to be turned on and/or off.
According to the present invention, the non-updated transfer source address at which ON data and/or OFF data was written is stored in the storage section, and the stored transfer source address and the updated transfer source address are compared with each other. Writing of the third data over the ON data and/or OFF data that was written at the matching address, and writing of ON data and/or OFF data over the third data are disabled.
Accordingly, if the transfer source addresses for the ON data and/or OFF data does not change between before and after updating of the phase at which the switch is to be controlled to be turned on and/or off, unnecessary writing into the predetermined region of the memory will be omitted.
According to the present invention, if ON data is written over third data that was written at the calculated transfer source address, ON data will also be written over third data that was written at an address distanced to the front/rear from the calculated transfer source address. Furthermore, if OFF data is written over third data that was written at the calculated transfer source address, OFF data will also be written over third data that was written at an address distanced to the front/rear from the calculated transfer source address.
Accordingly, since either or both of ON data and OFF data is written two times, on/off control of the switch is reliably performed.
According to the present invention, if a range of phases at which none of the plurality of switches, which are individually controlled to be turned on/off by one piece of the transfer data, is set in advance, a range of transfer source addresses from which the transfer data is DMA-transferred to the switch within the set range of phases is stored in the second storage section. In this range of transfer source addresses, third data is always stored. In this state, when, for example, a control other than on/off control is performed on the switch, another piece of third data that corresponds to the other control is written over the third data that was written at a suitable address within the range of transfer source addresses stored in the second storage section.
Accordingly, another control is performed on the switch, without the need of searching a transfer source address at which another piece of third data is allowed to be written over, and without affecting on/off control of the switch.
According to the present invention, both addresses over whose contents ON data and OFF data are respectively to be written are calculated from odd-numbered addresses or even-numbered addresses in the predetermined region of the memory. If, in this state, for example, a control other than on/off control is performed on the switch, and ON data and OFF data are written over the contents of the odd-numbered addresses, another piece of third data that corresponds to the other control will be written over the content of a suitable address of the even-numbered addresses. Furthermore, if ON data and OFF data are written over the contents of even-numbered addresses, another piece of third data that corresponds to the control will be written over the content of a suitable address of the odd-numbered addresses.
Accordingly, another control is performed on the switch as needed, without the need of searching a transfer source address at which another piece of third data is allowed to be written over, and without affecting on/off control of the switch.
According to the present invention, if processing for updating transfer data in the predetermined region of the memory is divided temporally into, for example, two parts, namely, first and second processes, a boundary between pieces of transfer data that are to be updated in the respective divided processes is set in advance. Then, while the transfer data located on the front side of the set boundary is DMA-transferred, another piece of transfer data is written over a suitable piece of transfer data on the rear side of the set boundary and is updated. Furthermore, while the transfer data located on the rear side of the set boundary is DMA-transferred, another piece of transfer data is written over a suitable piece of transfer data on the front side of the set boundary and is updated.
Accordingly, the phase at which the switch is controlled to be turned on/off is updated without affecting the on/off control of the switch.
According to the present invention, pieces of fixed control data irrelevant to on/off control of a switch are uniformly written in an entire predetermined region of a memory, ON data and OFF data are written over each of two of the pieces of control data to start DMA transfer, and thereby the switch is controlled to be turned on/off.
Accordingly, it is possible to reduce a processing load when controlling on/off of a switch whose various operations are controlled based on control data.
Hereinafter, the present invention will be described in detail with reference to the drawings illustrating embodiments thereof. The following will describe an example in which an intelligent power device, for which “SPOC” of Infineon AG is a typical example, specifically, a multiple channel IPD (hereinafter, referred to simply as “IPD”) having an SPI communication interface, is used as a switch of a switch device according to the present invention.
The switch circuit is also provided with an IPD (that corresponds to a switch) 18 including four MOSFETs (hereinafter, referred to simply as “FETs”) 181, and the SPI controller 17 and the IPD 18 are connected to each other via a master output/slave input (MOSI: Master Out Slave In) signal line and a master input/slave output (MISO: Master In Slave Out) signal line of SPI communication, and a clock (SCK: Serial Clock) signal line. In Embodiment 1, the SPI controller 17 is set as a master, and an SPI interface that is built in the IPD 18 and is not shown is set as a slave.
The RAM 13 includes a command table (that corresponds to a predetermined region) 131 in which a plurality of commands (that correspond to transfer data) that are to be transferred to the SPI controller 17 with DMA transfer by the DMA controller 15 are written, and a response table 132 in which responses that are to be transferred from the SPI controller 17 with DMA transfer are written. The size of the command table 131 defines the accuracy in duty when the above-described FETs 181 are controlled to be turned on/off (details will be described later).
The timer 14 generates, at a fixed period, DMA requests, which serve as triggers for the DMA controller 15 to perform DMA transfer with respect to the command table 131 and the response table 132. The DMA requests generated by the timer 14 are respectively given to two DMA channels (that will be described later) of the DMA controller 15.
The DMA controller 15 has a plurality of DMA channels for respectively accepting the plurality of DMA requests. The DMA controller 15 gives a signal (so-called “HOLD signal”) for requesting the CPU 11 to hold the bus when having accepted a DMA request, and executes DMA transfer in accordance with the accepted DMA request when having received an acknowledge signal (so-called “HOLDA signal”) given from the CPU 11. When series of DMA transfer that were set for the respective DMA channels are complete, the DMA controller 15 gives a DMA completion interrupt request to the interrupt controller 16.
The DMA controller 15 includes, for each DMA channel, a register indicating a DMA transfer source address, a register indicating a DMA transfer destination address, a register indicating a DMA transfer count, a register indicating a DMA transfer size, the count direction (increment/decrement/fixed) of the transfer source address, and the count direction (increment/decrement/fixed) of the transfer destination address, and a register indicating whether DMA transfer is enabled/disabled, for example. Each time a DMA transfer is executed, the transfer count is decremented by one.
The interrupt controller 16 is configured to be capable of accepting a plurality of interrupt requests, and gives a signal (so-called “INT signal”) for requesting the CPU 11 to interrupt when having accepted an interrupt request, and transmits, to the bus, an interrupt vector that corresponds to this interrupt request when having received an acknowledge signal (so-called “INTA signal”) given from the CPU 11. When the interrupt vector transmitted to the bus is read in the CPU 11, the CPU 11 is configured to execute interrupt processing that corresponds to the corresponding interrupt request. In Embodiment 1, the highest priority is set for the DMA completion interrupt request.
The SPI controller 17 includes a transmission buffer for buffering a command to be transmitted to the MOSI signal line, and a reception buffer for buffering a response that is received from the MISO signal line. An address mapped in the memory or an address of an input-output port is assigned to each of the transmission buffer and the reception buffer, and the transmission buffer and the reception buffer are accessed from the CPU 11 or the DMA controller 15 via the bus. In Embodiment 1, the SPI controller 17 transmits a clock to the SCK signal line only while a command is transmitted, and while a response is received.
Upon receiving a command from the MOSI signal line, the IPD 18 performs processing that corresponds to the command, and transmits a response serving as a processing result to the MISO signal line. Each of the four FETs 181 of the IPD 18 is constituted by an N channel-type MOSFET, and drains of the FETs 181 are connected to a +B electric power supply, and outputs 1, 2, 3, and 4 from sources thereof are supplied to a load 19. The four FETs 181 are respectively controlled to be turned on/off with different bits included in an output command received from the MOSI signal line.
According to the above-described configuration, in DMA transfer in which a head address of the command table 131 is set as a transfer source address, the address of the transmission buffer of the SPI controller 17 is set as a transfer destination address, and the count direction of the transfer destination address is set as “fixed”. The transfer size is set to 1 byte in conformity to the command length of the IPD 18. Furthermore, in DMA transfer in which the head address of the response table 132 is set as a transfer destination address, the address of the reception buffer of the SPI controller 17 is set as a transfer source address, the count direction of the transfer source address is set as “fixed”, and the transfer size is set to 1 byte. The transfer source address and the transfer destination address that are respectively set at the head addresses of the command table 131 and the response table 132 are incremented by one each time the DMA transfer is performed.
Accordingly, with DMA transfer controlled by the DMA controller 15, the commands written in the command table 131 are sequentially transferred to the transmission buffer of the SPI controller 17 in periods of the DMA requests generated by the timer 14, and are transmitted to the IPD 18. Furthermore, with DMA transfer controlled by the DMA controller 15, the responses that were received by the SPI controller 17 from the IPD 18 and were buffered by the reception buffer are sequentially transferred to the response table 132 in periods of the DMA requests generated by the timer 14.
Meanwhile, a clock transmitted to the SCK signal line by the SPI controller 17 is based on a signal that is generated by a frequency divider of the SPI controller 17 that is not shown dividing the frequency of the original clock that is not shown. In order for the SPI controller 17 to transmit one command to the MOSI signal line, a time period that is at least eight-fold as long as the period of the clock is needed, but a time interval in which a command is DMA-transferred to the transmission buffer of the SPI controller 17 is configured to be sufficiently longer than that time period. In other words, the division ratio of the frequency divider is selected so that the period of the clock is sufficiently shorter than the period that is ⅛ of the period of the DMA requests generated by the timer 14.
The following will describe commands and responses that are given and received between each of the command table 131 and the response table 132, and the IPD 18.
Twenty-six commands of commands A to Z in that order, for example, from the head address are written in the command table 131. The commands are DMA-transferred in periods of DMA requests generated by the timer 14. When the command Z, which was written at the end of the command table 131, is DMA-transferred to the transmission buffer of the SPI controller 17 (hereinafter, referred to simply as “transmission buffer”) at time t1, the command Z is transmitted to the MOSI signal line. The response that is transmitted to the MISO signal line during the transmission of the command Z is a response Y to the command Y, which is one command before the command Z.
On the other hand, during a time period between reception of a response X, which is one response before the response Y, and completion of reception of the response Y, the response X is held in the reception buffer of the SPI controller 17 (hereinafter, referred to simply as “reception buffer”). This response X is DMA-transferred to the response table 132 at almost the same time as the DMA transfer of the command Z at time t1. Because the DMA controller 15 does not perform two DMA transfers at the same time, a slight difference occurs in time between the DMA transfer of the command Z and the DMA transfer of the response X, but here the difference in time is left out of consideration.
Meanwhile, when the DMA transfer at time t1 is complete, the DMA completion interrupt occurs from the DMA controller 15 to the interrupt controller 16, and settings for the DMA controller 15 are configured in the interrupt processing that corresponds to this DMA completion interrupt. As a result, the transfer source address of the DMA transfer from the command table 131 to the transmission buffer is set at the head address of the command table 131, that is, the address at which the command A was written. Furthermore, the transfer destination address for the DMA transfer from the reception buffer to the response table 132 is set at the head address of the response table 132.
Then, at time t2, the command A, which was written at the head address of the command table 131, is DMA-transferred to the transmission buffer and is transmitted to the MOSI signal line, and a response Z is transmitted to the MISO signal line in the meantime, or the response Y is held in the reception buffer during a time period between the reception of the response Y and completion of reception of the response Z, and this response Y is transferred to the head address of the response table 132 at almost the same time as DMA transfer of the command A at time t2.
Similarly, thereafter, at time t3, the command B, which was written at the second address of the command table 131, is DMA-transferred to the transmission buffer, and the response Z held in the reception buffer is transferred to the second address of the response table 132. Furthermore, at time t4, the command C, which was written at the third address of the command table 131, is DMA-transferred to the transmission buffer, and a response A held in the reception buffer is transferred to the third address of the response table 132. It is to be noted that, in this way, a time lag for two addresses will occur between an offset in an address at which a command was written (a difference from the head address of the table), and an offset in address at which the response corresponding to the command is to be transferred.
The following will describe a specific example in which a FET 181 is controlled to be turned on/off based on a content of the command table 131.
Hereinafter, it is assumed that thirteen commands are written in the command table 131, unless otherwise noted. It is further assumed that, of the commands in the command table 131, the command at the first address controls the on/off state of the FET 181 at phase 0, and the command at the y-th (y=2, 3, . . . 10, 11, 12, 13) address controls the on/off state of the FET 181 at phase Pz (z=2, . . . a, b, c, d). Accordingly, the accuracy in duty when the FET 181 is controlled to be turned on/off is 7.7% (=100/13). For example, if the command table 131 has a size such that one hundred commands can be written, the accuracy in duty will be 1%.
The FETs 181 to be controlled by a command are respectively designated by the low-order 4 bits of the command. If the bit that corresponds to a FET 181 is 1 (or 0), this FET 181 is controlled to be turned on (or off). Hereinafter, unless otherwise noted, commands that control a specific target FET 181 to be turned on and off are respectively denoted by “ON command (that corresponds to ON data)” and “OFF command” (that corresponds to OFF data). “DIAG command” refers to a diagnosis command (that corresponds to third data) that is irrelevant to on/off control of the FET 181.
As shown in the lower stage of
In contrast, in Embodiment 1, first, as shown in the upper stage of
The following will describe the operation of the above-described switch circuit with reference to a flowchart illustrating the operation. The processing that will be described below is executed by the CPU 11 in accordance with a control program stored in advance in the ROM 12.
The ON phase and the OFF phase that are used in
In the flowchart described below, an ON command, an OFF command, and a DIAG command are respectively denoted by ON data, OFF data, and a diagnosis command (the same applies to other embodiments that will be described later).
When the processing of
Then, the CPU 11 reads out, from the RAM 13, an OFF phase (step S15), and calculates an OFF address (that corresponds to the transfer source address from which transfer data is DMA-transferred to the switch at the OFF phase) at which OFF data is to be written (which corresponds to step S16: calculating means), based on the read-out OFF phase. Then, the CPU 11 writes the OFF data over the diagnosis command written at the calculated OFF address (which corresponds to step S17: overwriting means), and stores the OFF address in the RAM 13 for later reference (which corresponds to step S18: storing means).
Then, the CPU 11 configures settings of disabling the controller 15 to perform DMA transfer (step S19), then configures settings of, for example, the transfer source address, and the count of transfer of DMA transfer (step S20), and lastly configures settings of enabling DMA transfer (step S21), and the processing of
After having configured settings of enabling DMA transfer, the DMA controller 15 accepts a fixed-periodic DMA requests from the timer 14, and the commands such as the DIAG commands, the ON command, and the OFF command that are written in the command table 131 are DMA-transferred to the SPI controller 17 one by one in a fixed period. If all the contents of the command table 131 have been DMA-transferred, it is sufficient to set that the processing shown in steps S19 to S21 of
As described above, according to Embodiment 1, all the commands in the command table 131 included in the RAM 13 are DMA-transferred in a period of 10 ms for example, and the DMA-transferred commands are given to the IPD 18 to control the IPD 18 (specifically, the FETs 181 of the IPD 18: the same applies to the following) to be turned on/off in the period of 10 ms. The commands are an ON/OFF commands (ON data)(OFF data) for controlling the IPD 18 to be turned on/off, or a DIAG (diagnosis) command irrelevant to the on/off control of the IPD 18, and, among them, the DIAG commands were written in advance in the entire region of the command table 131. Then, phases at which the IPD 18 is to be controlled to be turned on and off in the period of 10 ms are read out from the RAM 13, and the transfer source addresses (an ON address and an OFF address) of the commands that are DMA-transferred to the IPD 18 at the read-out phases are calculated, and the ON command and the OFF command are written over the DIAG commands written in advance at the calculated transfer source addresses.
That is, diagnosis commands, which are fixed control data irrelevant to the on/off control of the IPD 18, are uniformly written in the entire region of the command table 131, ON data and OFF data are written over the contents of an ON address and an OFF address in the command table 131 that respectively correspond to phases at which the IPD 18 is to be controlled to be turned on and off, then all the commands in the command table 131 are sequentially DMA-transferred, and thereby the IPD 18 is controlled to be turned on/off at the phases that correspond to the ON address and the OFF address at which the ON data and the OFF data were written.
Accordingly, it is possible to reduce a processing load when controlling on/off of a switch whose various operations are controlled by control data.
In contrast to Embodiment 1 that has an aspect in which updating of phases at which the IPD 18 is controlled to be turned on/off is out of consideration, Embodiment 2 has an aspect in which the processing of Embodiment 1 is executed and then the phases at which the IPD 18 is controlled to be turned on/off are updated.
Because a hardware configuration of a switch circuit according to Embodiment 2 is the same as that of Embodiment 1, like reference numerals are given to the corresponding components and redundant descriptions are omitted.
The following will describe a case in which the state, as shown in the lower stage of
When updating the control, it is configured such that the entire region of the command table 131 is filled up with the DIAG commands, as shown in the second stage of
Then, the ON address and the OFF address are updated based on the ON phase and the OFF phase that were newly read out from the RAM 13. It is here assumed that the ON address is the same address as that prior to the update, and the OFF address is the ninth address of the command table 131. Also, the ON command and the OFF command are written over the contents of the updated ON address and OFF address, and the content C of the command table 131 as shown in the third stage of
Note that a configuration is also possible in which it is determined whether or not the ON addresses (or the OFF addresses) before and after the update match each other, and if the ON addresses (or the OFF addresses) match each other, the DIAG command and the ON command (or OFF command) are not written over the ON address (or the OFF address).
The following will describe the operation of the above-described switch circuit with reference to a flowchart illustrating the operation. The processing described below is executed by the CPU 11 in accordance with a control program stored in advance in the ROM 12.
The processing of
When the processing of
If the two addresses determined by the comparison do not match each other (NO in step S35), the CPU 11 writes a diagnosis command over the ON address read out from the RAM 13 (which corresponds to step S36: second overwriting means), writes ON data over the diagnosis command written at the updated ON address (which corresponds to step S37: overwriting means), and stores the updated ON address in the RAM 13 (which corresponds to step S38: storing means). Note that, if, during calculation of an ON address, the ON address is stored in a register and the like (that corresponds to a storage section) of the CPU 11, the processing of step S38 will be omitted (the same applies to an OFF address that will be described later).
Then, the CPU 11 reads out, from the RAM 13, an OFF address that was stored in, for example, step S18 of
If the two addresses determined by the comparison do not match each other (NO in step S45), the CPU 11 writes a diagnosis command over the ON address read out from the RAM 13 (which corresponds to step S46: second overwriting means), writes OFF data over the diagnosis command t written at the updated OFF address (which corresponds to step S47: overwriting means), and stores the updated OFF address in the RAM 13 (which corresponds to step S48: storing means), and the processing of
Note that, in the flowchart above, in steps S35 and S45, it is determined whether or not the ON addresses and the OFF addresses before and after the update match each other, but it is also possible to advance the procedure to step S36 and/or step S46, without performing the determination of step S35 and/or step S45.
Accordingly, by updating the address of the command table 131 at which the ON command and/or the OFF command are to be written, the phases at which the FET 181 is controlled to be turned on/off are updated at an appropriate time.
As described above, according to Embodiment 2, prior to updating phases at which the IPD 18 is controlled to be turned on/off, the non-updated transfer source address (ON address and/or OFF address) at which an ON command (ON data) and/or an OFF command (OFF data) was written is temporarily stored, and a DIAG (diagnosis) command is written over the content of the stored transfer source address. Then, the transfer source address from which the command is DMA-transferred to the IPD 18 is updated at a new phase at which the IPD 18 is to be controlled to be turned on and/or off. Then, when the transfer source address for ON control of the IPD 18 is updated, an ON command is written over the updated transfer source address, and when the transfer source address for OFF control of the IPD 18 is updated, an OFF command is written over the updated transfer source address.
Accordingly, when updating an ON address and/or OFF address at which ON data and/or OFF data is to be written, it is possible to easily update the phase at which the IPD 18 is controlled to be turned on and/or off, by writing a diagnosis command over the content of the ON address and/or OFF address prior to the update, and writing the ON data and/or the OFF data over the content of the ON address and/or OFF address that were/was updated in accordance with the overwriting.
Moreover, according to Embodiment 2, the ON address and/or OFF address prior to the update is stored in the RAM 13, and the stored ON address and/or OFF address and the corresponding updated ON address and/or OFF address are compared with each other, and writing of DIAG commands over the ON data and/or OFF data written at the addresses that match each other, and writing of ON data and/or OFF data over the DIAG commands are disabled.
Accordingly, if there is no change in the ON addresses and/or OFF addresses before and after update at the phase at which the IPD 18 is to be controlled to be turned on and/or off, it is possible to omit unnecessary writing to the command table 131.
In contrast to Embodiment 1 that has an aspect in which an ON command and an OFF command are written only over the ON address and the OFF address in the command table 131 that respectively correspond to an ON phase and an OFF phase, Embodiment 3 has an aspect in which an ON command and an OFF command are written also over an address distanced from the ON address and the OFF address.
Because a hardware configuration of a switch circuit according to Embodiment 3 is the same as that of Embodiment 1, like reference numerals are given to the corresponding components and redundant descriptions are omitted.
As shown in
For example, if the ON phase at which the FET 181 is to be controlled to be turned on is phase P3 (or P4), an ON command is written also over the address that corresponds to phase P4 (or P3). Accordingly, even if the FET 181 is not controlled to be turned on at phase P3, the likelihood of the FET 181 being controlled to be turned on at phase P4 will increase. Similarly, if the OFF phase at which the FET 181 is to be controlled to be turned off is phase P9 (or Pa), an OFF command is written also over the address that corresponds to phase Pa (or P9). Accordingly, even if the FET 181 is not controlled to be turned off at phase P9, the likelihood of the FET 181 being controlled to be turned off at phase Pa will increase.
Moving to
For example, if the ON phase at which the FET 181 is to be controlled to be turned on is phase P3 (or P5), an ON command is written also over the address that corresponds to phase P5 (or P3). Accordingly, even if the FET 181 is not controlled to be turned on at phase P3, the likelihood of the FET 181 being controlled to be turned on at phase P5 will increase. Similarly, if the OFF phase at which the FET 181 is controlled to be turned off is phase P9 (or Pb), an OFF command is written also over the address that corresponds to phase Pb (or P9). Accordingly, even if the FET 181 is not controlled to be turned off at phase P9, the likelihood of the FET 181 being controlled to be turned off at phase Pb will increase.
The following will describe the operation of the above-described switch circuit with reference to a flowchart illustrating the operation. The processing described below is executed by the CPU 11 in accordance with a control program stored in advance in the ROM 12.
When the processing of
Then, the CPU 11 writes the ON data over the updated ON address (which corresponds to step S54: overwriting means), and further writes the ON data over the address distanced from the overwritten address by one address, or the address distanced from the overwritten address by two addresses or more (which corresponds to step S55: overwriting means). Then, the CPU 11 stores the updated ON address in the RAM 13 (which corresponds to step S56: storing means), and the procedure of
Note that in the flowchart above, a case where an ON phase is updated, but the flowchart that shows the processing procedure of the CPU 11 that updates OFF control of the FET 181 when an OFF phase is updated is the same as that of
As described above, according to Embodiment 3, when an ON command (ON data) is written over a DIAG command that was written at a calculated transfer source address (ON address), an ON command is written also over a DIAG command that was written at an address distanced to the front/rear from the calculated transfer source address by one address or more. Furthermore, when an OFF command (OFF data) is written over a DIAG command that was written at a calculated transfer source address (OFF address), an OFF command is written also over a DIAG command distanced to the front/rear from the calculated transfer source address by one address or more.
Accordingly, by writing either or both of ON data and OFF data two times, it is possible to reliably perform on/off control of the IPD 18.
In contrast to Embodiments 1 to 3 that have an aspect in which a command and a DIAG command for controlling a FET 181 to be turned on/off are DMA-transferred, Embodiment 4 has an aspect in which a command and a DIA command for controlling the FET 181 to be turned on/off, as well as another control command are DMA-transferred to the IPD 18.
Because a hardware configuration of a switch circuit according to Embodiment 4 is the same as that of Embodiment 1, like reference numerals are given to the corresponding components and redundant descriptions are omitted.
The content F of the command table 131 shown in the uppermost stage of
As in the example shown in
That is, when the other overwritten control command is transferred to the SPI controller 17 with DMA-transfer, and is further received by the IPD 18 with SPI communication, the IPD 18 is controlled by the other control command. Examples of the other control command include a command to cancel the FET 181 held in a latched state, and a command to switch a sence current with respect to the outputs 1 to 4.
As described above, according to Embodiment 4, when a range of phases at which none of the four FETs 181, which are independently controlled to be turned on and off by one command, is controlled to be turned on/off is set in advance, a range of transfer source addresses from which transfer data is to be DMA-transferred to a switch in the set range of phases is stored in the RAM 13. DIAG (diagnosis) commands are always held in this range of transfer source addresses. In this state, when, for example, a control other than the on/off control is performed on the IPD 18, another control command that corresponds to the other control is written over the DIAG command that was written at a suitable address in the range of transfer source addresses stored in the RAM 13.
Accordingly, it is possible to perform another control on the IPD 18 without the need of searching a transfer source address at which another control command is allowed to be written over, and without affecting on/off control of the IPD 18.
In contrast to Embodiment 4 that has an aspect in which a range of transfer source addresses at which a DIAG command is to always be held is stored, and another control command is written over the content of a suitable address within the stored range of the addresses, Embodiment 5 has an aspect in which a transfer source address over whose content an ON command or an OFF command is to be written, and a transfer source address over which another control command is to be written are separately and alternately prepared.
Because a hardware configuration of a switch circuit according to Embodiment 5 is the same as that of Embodiment 1, like reference numerals are given to the corresponding components and redundant descriptions are omitted.
In Embodiment 5, for example, the size of the command table 131 is set as a size in which 200 commands can be written, and DIAG commands are written in advance in the entire region of the command table 131 (corresponding to writing means). When an ON command or an OFF command is written over the DIAG commands in the command table 131, an address at which overwriting is to be performed is calculated from 100 odd-numbered addresses included in the command table 131 (corresponding to second calculating means). Accordingly, the accuracy in duty when the IPD 18 is controlled to be turned on/off is 1%. Furthermore, when another control command is written over the DIAG command in the command table 131, overwriting is performed on the content of a suitable address of 100 even-numbered addresses (corresponding to fourth overwriting means). The other control command may also be written over the contents of a plurality of even-numbered addresses.
Accordingly, by separating an address over which a command for controlling the FET 181 to be turned on/off is to be written from an address over which a control command other than a DIAG command is to be written, it is possible to give a suitable control command to the IPD 18 at a suitable phase in a period in which the FET 181 is controlled to be turned on/off.
Note that a configuration is also possible in which another control command is written over the contents of odd-numbered addresses, and an ON command or an OFF command is written over the contents of even-numbered addresses.
As described above, according to Embodiment 5, both addresses over whose contents an ON command (ON data) and an OFF command (OFF data) are respectively to be written are calculated from odd-numbered addresses or even-numbered addresses in the command table 131. If, in this state, for example, a control other than on/off control is performed on the IPD 18, and an ON command and an OFF command are written over the contents of odd-numbered addresses, another control command is written over the DIAG command that was written at a suitable address over which an even-numbered command is to be written. Furthermore, if an ON command and an OFF command are written over the contents of even-numbered addresses, another control command will be written over the DIAG command that was written at a suitable address over which an odd-numbered command is to be written.
Accordingly, it is possible to perform another control on the IPD 18 as needed, without the need of searching a transfer source address at which another control command is allowed to be written over, and without affecting on/off control of the IPD 18.
Furthermore, according to Embodiment 5, it is possible to control the IPD 18 to be turned on/off with the duty of the same accuracy as the case of Embodiment 1 in which the accuracy in duty when the IPD 18 is controlled to be turned on/off is set to 1%, by setting the size of the command table 131 as being twice larger than that of Embodiment 1.
In contrast to Embodiments 1 to 5 have an aspect in which a timing to update a content of the command table 131 is not clearly indicated, Embodiment 6 has an aspect in which contents of different regions in the command table 131 are updated at timings of a first half and a second half of a period in which the FET 181 is controlled to be turned on/off.
Because a hardware configuration of a switch circuit according to Embodiment 6 is the same as that of Embodiment 1, like reference numerals are given to the corresponding components and redundant descriptions are omitted.
Meanwhile, DMA transfer in which an address in the command table 131 is set as a transfer source address, and updating processing for updating the command table 131 by the CPU 11 cannot directly compete against each other. However, if, for example, the CPU 11 updates an ON address, and the contents of the ON addresses before and after update are DMA-transferred after a DIAG command was written over the content of the non-updated ON address and before an ON command is written over the updated ON address, the FET 181 will not be turned on in this period, and on/off control of the FET 181 is not possible for one period. In order to avoid this, it is sufficient to ensure that, during a period in which the CPU 11 updates one partial region (or another partial region) of the command table 131, the one partial region (or the other partial region) is not subjected to DMA transfer.
As shown in the uppermost stage of
Note that the phases at which these two updating processes are to be started are not limited to phases 0 and P7, as long as the two updating processes are in execution and regions that are respectively being subjected to the processes are not DMA-transferred, and the boundary of the address is also not limited to the address that corresponds to an intermediate phase between phases P6 and P7. For example, the two updating processes may be started temporally at equal intervals in a period in which the FET 181 is controlled to be turned on/off. Furthermore, the updating processes may be started three times or more in the period, and in this case, the addresses of the boundaries for regions to be subjected to updating of the updating process may be set appropriately based on this count of the processes that are to be started.
The following will describe a case in which one of the updating processes to be started at phases 0 and P7 can be omitted.
As shown in the lowermost stage of
In contrast, one of the commands of the seventh to thirteenth addresses that correspond to phases P7 to Pd is an OFF command, and the remaining commands are DIAG commands, and the type of command depends on the OFF phase at which the FET 181 is to be controlled to be turned off (denoted by “OFF/DG” in the figure). Accordingly, updating of a command by the updating process to be started at phase P0 needs to be performed.
Moving to
In contrast, one of the commands at the first to sixth addresses that correspond to phases P0 to P6 is an ON command, and the remaining commands are DIAG commands, and the type of command depends on the OFF phase at which the FET 181 is to be controlled to be turned off (denoted by “ON/DG” in the figure). Accordingly, updating of a command by the updating process to be started at phase P7 needs to be performed.
As described above, according to Embodiment 6, the processing for updating the commands in the command table 131 is divided into two updating processes that are started at phases 0 and P7, and the boundary between the commands to be updated in the divided updating processes is set at the address that corresponds to the middle of phases P6 and P7. Then, while the commands located on the front side of the set boundary are DMA-transferred, another command is written over a suitable command located on the rear side of the set boundary and is updated. Furthermore, while the commands located on the rear side of the set boundary are DMA-transferred, another command is written over a suitable command located on the front side of the set boundary and is updated.
Accordingly, it is possible to update a phase at which the IPD 18 is controlled to be turned on/off, without affecting on/off control of the IPD 18.
Furthermore, according to Embodiment 6, a starting period in which processing for updating commands in the command table 131 is started is set as being just a half of a PWM period in which the IPD 18 is controlled to be turned on/off, and thereby commands in the regions, on the front side and the rear side, of the command table 131 are updated by processes that are started in the respective starting periods of even numbered and odd numbered addresses for example, making it possible to simplify the design of software, and also to reliably update all the commands in the command table 131.
The embodiments disclosed here are exemplary in all respect and are to be construed as not limiting. The scope of the present invention is defined not in the sense of the description above but the claims, and is intended to include all modifications within the sense and scope equivalent to the claims. Furthermore, the technical features described in the embodiments can be combined with each other.
Number | Date | Country | Kind |
---|---|---|---|
2014-091944 | Apr 2014 | JP | national |
This application is the U.S. national stage of PCT/JP2015/056620 filed Mar. 6, 2015, which claims priority of Japanese Patent Application No. JP 2014-091944 filed Apr. 25, 2014.
Filing Document | Filing Date | Country | Kind |
---|---|---|---|
PCT/JP2015/056620 | 3/6/2015 | WO | 00 |