Hello, I am having trouble getting the Hc12 A4 chip to work in expanded wide mode. Specifically I am having problems reading and or writing to an eeprom, which has been checked manually and is working correctly. When trying to read from the EEPROM only the even addresses are being read correctly. My output is included. I have set the mode, windef, chip select, and pear registers on init. Any ideas would be great. -Heath ====================Init code============================ #define HC12_MODE_SMODN 0x80 #define HC12_MODE_MODB 0x40 #define HC12_MODE_MODA 0x20 #define HC12_MODE_ESTR 0x10 #define HC12_WINDEF_DWEN 0x80 #define HC12_WINDEF_PWEN 0x40 #define HC12_CSCTL0_CSP1E 0x40 #define HC12_CSCTL0_CSP0E 0x20 #define HC12_CSCTL0_CSDE 0x10 #define HC12_PEAR_RDWE 0x04 Hc12Reg.Mode = ;HC12_MODE_SMODN | HC12_MODE_MODB | HC12_MODE_MODA | HC12_MODE_ESTR; /*Normal expanded wide*/ Hc12Reg.Windef = HC12_WINDEF_PWEN | HC12_WINDEF_DWEN; /*Enable PWEN DWEN*/ Hc12Reg.Pear = HC12_PEAR_RDWE; /*Enable PE2 pin for R/W*/ Hc12Reg.Csctl0 |= HC12_CSCTL0_CSP1E | HC12_CSCTL0_CSP0E | HC12_CSCTL0_CSDE; /* Enable program window and data window chip selects*/ ================Functions to read and write ===================== INT16U ReadEEPROMWord(ExtAddrtype addr){ INT16U *pt; Hc12Reg.Ppage = addr.msb; // set Ppage A21-A14 pt = (INT16U*)(0x8000 + addr.lsw); return *pt; } void WriteEEPROMWord(ExtAddrtype addr, INT16U data){ INT16U *pt; Hc12Reg.Ppage = addr.msb; // set PPage A21-A14 pt = (INT16U*)(0x8000 + addr.lsw); *pt = data; } ===================Output====================================== Write EE: 0 @ 0x8000 + 0 Write EE: 1 @ 0x8000 + 1 Write EE: 2 @ 0x8000 + 2 Write EE: 3 @ 0x8000 + 3 Write EE: 4 @ 0x8000 + 4 Write EE: 5 @ 0x8000 + 5 Write EE: 6 @ 0x8000 + 6 Write EE: 7 @ 0x8000 + 7 Write EE: 8 @ 0x8000 + 8 Write EE: 9 @ 0x8000 + 9 //That is write value to 0x8000 plus an offset location Read EE : 0 @ 0x8000 + 0 Read EE : 0 @ 0x8000 + 1 Read EE : 2 @ 0x8000 + 2 Read EE : 0 @ 0x8000 + 3 Read EE : 4 @ 0x8000 + 4 Read EE : 0 @ 0x8000 + 5 Read EE : 6 @ 0x8000 + 6 Read EE : 0 @ 0x8000 + 7 Read EE : 8 @ 0x8000 + 8 Read EE : 0 @ 0x8000 + 9 |
|
hc12 A4 in expanded wide mode
Started by ●July 14, 2004
Reply by ●July 14, 20042004-07-14
Heath, You're in expanded wide mode. Is this a 16 bit wide EEPROM? If you're in wide mode, set LSTRE in the PEAR register. You need the /LSTRB signal to do byte-wide writes to external wide memories. Stephen -- Stephen Trier Technical Development Lab Cleveland FES Center |
|
Reply by ●July 15, 20042004-07-15
Hey thanks, that helped us out. If you know of any more gotchas with the HC12 in expanded wide, let me know. Thanks, Heath --- In , "Stephen Trier" <sct@p...> wrote: > Heath, > > You're in expanded wide mode. Is this a 16 bit wide EEPROM? > > If you're in wide mode, set LSTRE in the PEAR register. You need the > /LSTRB signal to do byte-wide writes to external wide memories. > > Stephen > > -- > Stephen Trier > Technical Development Lab > Cleveland FES Center > sct@p... |