In the Start data (local data) of the Startup OBs OB100, OB101 and OB102 there is the variable OB10x_STOP (x = 0,1,2). It contains the event ID of the last stop cause from the diagnostics buffer. With the SIMATIC S7-400 CPUs this variable can still be read after an overall reset.
With the SIMATIC S7-300 CPUs the OB100_STOP variable is no longer occupied after an overall reset.
A list of possible event IDs is available in the reference manual "System Software for S7-300/400 System and Standard Functions", section 34.5 "Event Class 4 - Stop Events and Other Mode Changes" in Entry ID 1214574.