This paper provides an analytical insight into the observed nonlinear behaviour of a simple widely used power electronic circuit (the buck converter) and draws parallels with a wider class of piecewise-smooth systems. After introducing the buck converter model and background, the most fascinating features of its dynamical behaviour are reviewed. So-called grazing and sliding solutions are discussed and their role in determining many of the buck converter's dynamical oddities is demonstrated. In particular, a local map is studied which explains how grazing bifurcations cause sharp turning points in the bifurcation diagram of periodic orbits. Moreover, these orbits are shown to accumulate onto a sliding trajectory through a `spiralling' impact adding scenario. The structure of such a diagram is derived analytically and is shown to be closely related to the analysis of homoclinic bifurcations. The results are shown to match perfectly with numerical simulations. The sudden jump to large-scale chaos and the fingered structure of the resulting attractor are also explained.