Capacitors with PN or Schottky junction