
643 So.2d 1209 (1994)
Reginald BYRD, Appellant,
v.
STATE of Florida, Appellee.
Nos. 92-2104, 93-1627.
District Court of Appeal of Florida, First District.
October 24, 1994.
Nancy A. Daniels, Public Defender, P. Douglas Brinkmeyer, Asst. Public Defender, for appellant.
Robert A. Butterworth, Atty. Gen., Joe S. Garwood, Asst. Atty. Gen., for appellee.
PER CURIAM.
Reginald Byrd appeals two judgments and sentences challenging the denial of his motion to withdraw plea and motion to vacate sentence, the use of a sentencing guidelines scoresheet which includes habitual offender offenses as primary and additional offenses at conviction, and the trial court's failure to award Byrd credit for the time he spent in a state hospital. We reverse.
The trial court erred in denying Byrd's motion to withdraw plea and motion to vacate sentence in Case No. 90-575. At the time Byrd entered his plea, the trial court failed to determine whether Byrd was aware of the maximum penalty or the mandatory minimum penalty. "[B]efore a court may accept a guilty or nolo plea it must determine on the record that the defendant is aware of the `maximum possible penalty provided by law' that may be imposed for the crime." Ashley v. State, 614 So.2d 486, 488 (Fla. 1993). See Fla.R.Crim.P. 3.172(c)(1); Green v. State, 406 So.2d 1148 (Fla. 1st DCA 1981), affirmed, 421 So.2d 508 (Fla. 1982). The defendant must also be made aware of any mandatory minimum penalty. Fla. R.Crim.P. 3.172(c)(1); Green v. State, 406 So.2d 1148 (Fla. 1st DCA 1981), affirmed, 421 So.2d 508 (Fla. 1982). Consequently, we reverse. On remand, Byrd may withdraw his plea.
Byrd correctly argues and the state concedes that the sentencing guidelines scoresheet used in Case No. 91-350 was incorrect in that it included habitual offender offenses as primary and additional offenses at conviction. Alloway v. State, 593 So.2d 1193 (Fla. 1st DCA 1992); Wyche v. State, 576 So.2d 884 (Fla. 1st DCA 1991). The scoresheet also inaccurately listed a count of possession of a firearm by a convicted felon, despite the dismissal of that charge. A corrected scoresheet results in a lower recommended *1210 sentence and permitted sentence. We reverse the sentence in Case No. 91-350 and remand for resentencing with a corrected scoresheet. On remand the trial court may consider whether a departure sentence is appropriate. Roberts v. State, 547 So.2d 129 (Fla. 1989). See Alloway v. State, 593 So.2d 1193 (Fla. 1st DCA 1992).
Byrd and the state also agree that the sentences in both cases should be remanded for a determination of credit for the time Byrd spent in a state hospital. Tal-Mason v. State, 515 So.2d 738 (Fla. 1987) (defendant entitled to credit for pre-conviction detention in a mental institutional for incompetence to stand trial). Accordingly, we remand for such a determination.
REVERSED.
ALLEN, KAHN and MICKLE, JJ., concur.
