not sure where this should go, but i couldnt use the timer on my 16f1826 enhanced pic micro. the culprit was in the timer.h file, the 16f1826 has TMR1CS0 and TMR1CS1 because of the capacitive sensors being able to be used as timer inputs (or something like that) im working on modifying the code to work with this chip and will post the updated code on here for anyone interested. this code im going to post shouldnt change function of normal chips but adds the changes needed for TMR1CS0 and TMR1CS1 (i also remembered i added TMR0CS in place of T0SE for timer0, im going to check over and test any other timers on this chip before posting the code, maybe the developer would like to put this code in the updates?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tested the code I modified with a non 16f1826 chip and the way I had the "#ifndef" in there made the compile fail. I've made the required changes and it should now work with the 16f1826, and with any other chip is used to work with. I'm a beginner at C code and really really beginner at understanding ASM codes, I just used my common sense to figure these problems out.
just to add on a little more support for the 16f1825 someone sent me a working eeprom routine for this chip, because the one included with gcbasic didnt work for my chip. I have tested this as working with my chip, but i dont know if it breaks support for the more standard chips.
' EEPROM routines for Great Cow BASIC'Copyright(C)2006-2007HughConsidine' This library is free software; you can redistribute it and/or'modifyitunderthetermsoftheGNULesserGeneralPublic' License as published by the Free Software Foundation; either'version2.1oftheLicense,or(atyouroption)anylaterversion.' This library is distributed in the hope that it will be useful,'butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU'LesserGeneralPublicLicenseformoredetails.' You should have received a copy of the GNU Lesser General Public'Licensealongwiththislibrary;ifnot,writetotheFreeSoftware' Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA'********************************************************************************'IMPORTANT:'THISFILEISESSENTIALFORSOMEOFTHECOMMANDSINGCBASIC.DONOTALTERTHISFILE'UNLESS YOU KNOW WHAT YOU ARE DOING. CHANGING THIS FILE COULD RENDER SOME GCBASIC'COMMANDSUNUSABLE!'********************************************************************************'Updates:' 3/5/2006: Program EEPROM read/write added'16/5/2006: WritemodedisabledatendofEPWrite' 23/5/2006: EPWrite and EPRead changed to stop use of temporary vars'19/8/2006: ProgramEEPROMalteredtotakeinputasword' 9/2/2007: Bug fix: EEPGD bit not set if not present'5/8/2007: Alteredtousealiastoaccessaddress,datavars' 4/9/2007: Data EEPROM code altered to support AVR'15/10/2007: Bugfix: FREEbitnotsetifnotpresent,alteredtouseIntOn/IntOfftocontrolinterrupt' 4/12/2007: Added In/Out to parameters'17/6/2008: AlteredtomakeEPReadasystemsub,toallowuseinReadTable' 19/4/2009: Bugfixes for AVR, allow EEPE instead of EEWEsub EPWrite(In EEAddress, In EEDataValue)#IFDEF PIC 'Variablealias#IFNDEFVar(EEADRH)DimEEAddressAliasEEADR#ENDIF#IFDEFVar(EEADRH)DimEEAddressAsWordAliasEEADRH,EEADR#ENDIF#IFDEFVar(EEDATA)DimEEDataValueAliasEEDATA#ENDIF#IFDEFVar(EEDATL)DimEEDataValueAliasEEDATL#ENDIF'Disable interrupt IntOff 'Selectdatamemory#IFDEFBit(EEPGD)SETEECON1.EEPGDOFF#ENDIF#IFDEFBit(CFGS)SetEECON1.CFGSOFF#ENDIF'Start write SET EECON1.WREN ON EECON2 = 0x55 EECON2 = 0xAA SET EECON1.WR ON SET EECON1.WREN OFF 'WaitforwritetocompleteWAITWHILEEECON1.WRONSETEECON1.WRENOFF'Restore interrupt IntOn#ENDIF#IFDEF AVR 'Variablealias#IFDEFVar(EEARH)DimEEAddressAsWordAliasEEARH,EEARL#ENDIF#IFNDEFVar(EEARH)#IFDEFVar(EEAR)DimEEAddressAliasEEAR#ENDIF#ENDIFDimEEDataValueAliasEEDR'Enable write #IFDEF Bit(EEMWE) Set EECR.EEMWE On #ENDIF #IFNDEF Bit(EEMWE) #IFDEF Bit(EEMPE) Set EECR.EEMPE On #ENDIF #ENDIF 'Startwrite,waitforittocomplete#IFDEFBit(EEWE)SetEECR.EEWEOnWaitUntilEECR.EEWEOff#ENDIF#IFNDEFBit(EEWE)#IFDEFBit(EEPE)SetEECR.EEPEOnWaitUntilEECR.EEPEOff#ENDIF#ENDIF#ENDIFendsub'EPRead made into system subroutine'ConstantaddedtoallowittostillbereferredtoasEPRead#defineEPReadSysEPReadsubSysEPRead(InEEAddress,OutEEDataValue)#IFDEFPIC'Variable alias #IFNDEF Var(EEADRH) Dim EEAddress Alias EEADR #ENDIF #IFDEF Var(EEADRH) Dim EEAddress As Word Alias EEADRH, EEADR #ENDIF #IFDEF Var(EEDATA) Dim EEDataValue Alias EEDATA #ENDIF #IFDEF Var(EEDATL) Dim EEDataValue Alias EEDATL #ENDIF 'DisableinterruptIntOff'Select data memory #IFDEF Bit(EEPGD) SET EECON1.EEPGD OFF #ENDIF #IFDEF Bit(CFGS) Set EECON1.CFGS OFF #ENDIF 'ReadSETEECON1.RDON'Restore interrupt IntOn#ENDIF#IFDEF AVR 'Variablealias#IFDEFVar(EEARH)DimEEAddressAsWordAliasEEARH,EEARL#ENDIF#IFNDEFVar(EEARH)#IFDEFVar(EEAR)DimEEAddressAliasEEAR#ENDIF#ENDIFDimEEDataValueAliasEEDR'Start read Set EECR.EERE On#ENDIF end subfunction ReadEP(EEAddress)#IFDEF PIC 'Variablealias#IFNDEFVar(EEADRH)DimEEAddressAliasEEADR#ENDIF#IFDEFVar(EEADRH)DimEEAddressAsWordAliasEEADRH,EEADR#ENDIF#IFDEFVar(EEDATA)DimEEDataValueAliasEEDATA#ENDIF#IFDEFVar(EEDATL)DimEEDataValueAliasEEDATL#ENDIF'Disable interrupt IntOff 'Selectdatamemory#IFDEFBit(EEPGD)SETEECON1.EEPGDOFF#ENDIF#IFDEFBit(CFGS)SetEECON1.CFGSOFF#ENDIF'Read SET EECON1.RD ON ReadEP = EEDataValue 'RestoreinterruptIntOn#ENDIF#IFDEFAVR'Variable alias #IFDEF Var(EEARH) Dim EEAddress As Word Alias EEARH, EEARL #ENDIF #IFNDEF Var(EEARH) #IFDEF Var(EEAR) Dim EEAddress Alias EEAR #ENDIF #ENDIF Dim EEDataValue Alias EEDR 'StartreadSetEECR.EEREOn#ENDIFendfunctionsubProgramWrite(InEEAddress,InEEDataWord)#IFDEFPICDimEEAddressAsWordAliasEEADRH,EEADR#IFDEFVar(EEDATA)DimEEDataWordAsWordAliasEEDATH,EEDATA#ENDIF#IFDEFVar(EEDATL)DimEEDataWordAsWordAliasEEDATH,EEDATL#ENDIF'Disable Interrupt IntOff 'SelectprogrammemorySETEECON1.EEPGDON#IFDEFBit(CFGS)SetEECON1.CFGSOFF#ENDIF'Enable write SET EECON1.WREN ON #ifdef bit(FREE) SET EECON1.FREE OFF #endif 'WriteenablecodeEECON2=0x55EECON2=0xAA'Start write, wait for it to finish SET EECON1.WR ON NOP NOP SET EECON1.WREN OFF 'EnableInterruptIntOn#ENDIFendsubsubProgramRead(InEEAddress,OutEEDataWord)DimEEAddressAsWordAliasEEADRH,EEADR#IFDEFVar(EEDATA)DimEEDataWordAsWordAliasEEDATH,EEDATA#ENDIF#IFDEFVar(EEDATL)DimEEDataWordAsWordAliasEEDATH,EEDATL#ENDIF'Disable Interrupt IntOff 'SelectprogrammemorySETEECON1.EEPGDON#IFDEFBit(CFGS)SetEECON1.CFGSOFF#ENDIF'Start read, wait for it to finish SET EECON1.RD ON NOP NOP 'EnableinterruptIntOnendsubsubProgramErase(InEEAddress)DimEEAddressAsWordAliasEEADRH,EEADR'Disable Interrupt IntOff 'SelectprogrammemorySETEECON1.EEPGDON#IFDEFBit(CFGS)SetEECON1.CFGSOFF#ENDIFSETEECON1.WRENON#ifdefbit(FREE)SETEECON1.FREEON#endifEECON2=0x55EECON2=0xAASETEECON1.WRONNOPNOP#ifdefbit(FREE)SETEECON1.FREEOFF#endifSETEECON1.WRENOFF'EnableinterruptIntOnendsub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
not sure where this should go, but i couldnt use the timer on my 16f1826 enhanced pic micro. the culprit was in the timer.h file, the 16f1826 has TMR1CS0 and TMR1CS1 because of the capacitive sensors being able to be used as timer inputs (or something like that) im working on modifying the code to work with this chip and will post the updated code on here for anyone interested. this code im going to post shouldnt change function of normal chips but adds the changes needed for TMR1CS0 and TMR1CS1 (i also remembered i added TMR0CS in place of T0SE for timer0, im going to check over and test any other timers on this chip before posting the code, maybe the developer would like to put this code in the updates?
This code compiled properly but I havent tested it yet on the actual chip, but here it is anyway
I tested the code I modified with a non 16f1826 chip and the way I had the "#ifndef" in there made the compile fail. I've made the required changes and it should now work with the 16f1826, and with any other chip is used to work with. I'm a beginner at C code and really really beginner at understanding ASM codes, I just used my common sense to figure these problems out.
I'll be happy to add those changes, thanks!
just to add on a little more support for the 16f1825 someone sent me a working eeprom routine for this chip, because the one included with gcbasic didnt work for my chip. I have tested this as working with my chip, but i dont know if it breaks support for the more standard chips.