Meaningful information on the internal state of a battery can be derived by measuring its impedance. Accordingly, battery management systems based on electrochemical impedance spectroscopy are now recognized as a feasible solutions for online battery control and diagnostic. Since the impedance of a battery is always changing along with its state of charge and aging effects, it is important to have a stable impedance reference in order to calibrate and test a battery management system. In this work we propose a programmable impedance emulator that in principle could be used for the calibration of any battery management system based on electrochemical impedance spectroscopy. A digital finite-impulse-response filter is implemented, whose frequency response is programmed so as to reproduce exactly the impedance of a real battery in the frequency domain. The whole design process of the filter is presented in detail. An analytical expression for the impedance of real battery in the frequency domain is derived from an equivalent circuit model. The model is validated both through numerical simulations and experimental tests. In particular, the filter is implemented on a low-cost microcontroller unit, and the emulated impedance is measured by means of a custom-made electrochemical impedance spectroscopy measuring system, and verified by using standard commercial bench instruments. Results on this prototype show the feasibility of using the proposed emulator as a fully controllable and low-cost reference for calibrating battery impedance measurement systems.