2
0

atmega16hvbrevb.pp 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  1. unit ATmega16HVBrevB;
  2. {$goto on}
  3. interface
  4. var
  5. PINA: byte absolute $20; // Port A Input Pins
  6. DDRA: byte absolute $21; // Port A Data Direction Register
  7. PORTA: byte absolute $22; // Port A Data Register
  8. PINB: byte absolute $23; // Port B Input Pins
  9. DDRB: byte absolute $24; // Port B Data Direction Register
  10. PORTB: byte absolute $25; // Port B Data Register
  11. PINC: byte absolute $26; // Port C Input Pins
  12. PORTC: byte absolute $28; // Port C Data Register
  13. TIFR0: byte absolute $35; // Timer/Counter Interrupt Flag register
  14. TIFR1: byte absolute $36; // Timer/Counter Interrupt Flag register
  15. OSICSR: byte absolute $37; // Oscillator Sampling Interface Control and Status Register
  16. PCIFR: byte absolute $3B; // Pin Change Interrupt Flag Register
  17. EIFR: byte absolute $3C; // External Interrupt Flag Register
  18. EIMSK: byte absolute $3D; // External Interrupt Mask Register
  19. GPIOR0: byte absolute $3E; // General Purpose IO Register 0
  20. EECR: byte absolute $3F; // EEPROM Control Register
  21. EEDR: byte absolute $40; // EEPROM Data Register
  22. EEAR: word absolute $41; // EEPROM Read/Write Access
  23. EEARL: byte absolute $41; // EEPROM Read/Write Access
  24. EEARH: byte absolute $42; // EEPROM Read/Write Access;
  25. GTCCR: byte absolute $43; // General Timer/Counter Control Register
  26. TCCR0A: byte absolute $44; // Timer/Counter 0 Control Register A
  27. TCCR0B: byte absolute $45; // Timer/Counter0 Control Register B
  28. TCNT0: word absolute $46; // Timer Counter 0 Bytes
  29. TCNT0L: byte absolute $46; // Timer Counter 0 Bytes
  30. TCNT0H: byte absolute $47; // Timer Counter 0 Bytes;
  31. OCR0A: byte absolute $48; // Output Compare Register 0A
  32. OCR0B: byte absolute $49; // Output Compare Register B
  33. GPIOR1: byte absolute $4A; // General Purpose IO Register 1
  34. GPIOR2: byte absolute $4B; // General Purpose IO Register 2
  35. SPCR: byte absolute $4C; // SPI Control Register
  36. SPSR: byte absolute $4D; // SPI Status Register
  37. SPDR: byte absolute $4E; // SPI Data Register
  38. SMCR: byte absolute $53; // Sleep Mode Control Register
  39. MCUSR: byte absolute $54; // MCU Status Register
  40. MCUCR: byte absolute $55; // MCU Control Register
  41. SPMCSR: byte absolute $57; // Store Program Memory Control and Status Register
  42. SP: word absolute $5D; // Stack Pointer
  43. SPL: byte absolute $5D; // Stack Pointer
  44. SPH: byte absolute $5E; // Stack Pointer ;
  45. SREG: byte absolute $5F; // Status Register
  46. WDTCSR: byte absolute $60; // Watchdog Timer Control Register
  47. CLKPR: byte absolute $61; // Clock Prescale Register
  48. PRR0: byte absolute $64; // Power Reduction Register 0
  49. FOSCCAL: byte absolute $66; // Fast Oscillator Calibration Value
  50. PCICR: byte absolute $68; // Pin Change Interrupt Control Register
  51. EICRA: byte absolute $69; // External Interrupt Control Register
  52. PCMSK0: byte absolute $6B; // Pin Change Enable Mask Register 0
  53. PCMSK1: byte absolute $6C; // Pin Change Enable Mask Register 1
  54. TIMSK0: byte absolute $6E; // Timer/Counter Interrupt Mask Register
  55. TIMSK1: byte absolute $6F; // Timer/Counter Interrupt Mask Register
  56. VADC: word absolute $78; // VADC Data Register Bytes
  57. VADCL: byte absolute $78; // VADC Data Register Bytes
  58. VADCH: byte absolute $79; // VADC Data Register Bytes;
  59. VADCSR: byte absolute $7A; // The VADC Control and Status register
  60. VADMUX: byte absolute $7C; // The VADC multiplexer Selection Register
  61. DIDR0: byte absolute $7E; // Digital Input Disable Register
  62. TCCR1A: byte absolute $80; // Timer/Counter 1 Control Register A
  63. TCCR1B: byte absolute $81; // Timer/Counter1 Control Register B
  64. TCNT1: word absolute $84; // Timer Counter 1 Bytes
  65. TCNT1L: byte absolute $84; // Timer Counter 1 Bytes
  66. TCNT1H: byte absolute $85; // Timer Counter 1 Bytes;
  67. OCR1A: byte absolute $88; // Output Compare Register 1A
  68. OCR1B: byte absolute $89; // Output Compare Register B
  69. TWBR: byte absolute $B8; // TWI Bit Rate register
  70. TWSR: byte absolute $B9; // TWI Status Register
  71. TWAR: byte absolute $BA; // TWI (Slave) Address register
  72. TWDR: byte absolute $BB; // TWI Data register
  73. TWCR: byte absolute $BC; // TWI Control Register
  74. TWAMR: byte absolute $BD; // TWI (Slave) Address Mask Register
  75. TWBCSR: byte absolute $BE; // TWI Bus Control and Status Register
  76. ROCR: byte absolute $C8; // Regulator Operating Condition Register
  77. BGCCR: byte absolute $D0; // Bandgap Calibration Register
  78. BGCRR: byte absolute $D1; // Bandgap Calibration of Resistor Ladder
  79. BGCSR: byte absolute $D2; // Bandgap Control and Status Register
  80. CHGDCSR: byte absolute $D4; // Charger Detect Control and Status Register
  81. CADAC0: byte absolute $E0; // ADC Accumulate Current
  82. CADAC1: byte absolute $E1; // ADC Accumulate Current
  83. CADAC2: byte absolute $E2; // ADC Accumulate Current
  84. CADAC3: byte absolute $E3; // ADC Accumulate Current
  85. CADIC: word absolute $E4; // CC-ADC Instantaneous Current
  86. CADICL: byte absolute $E4; // CC-ADC Instantaneous Current
  87. CADICH: byte absolute $E5; // CC-ADC Instantaneous Current;
  88. CADCSRA: byte absolute $E6; // CC-ADC Control and Status Register A
  89. CADCSRB: byte absolute $E7; // CC-ADC Control and Status Register B
  90. CADCSRC: byte absolute $E8; // CC-ADC Control and Status Register C
  91. CADRCC: byte absolute $E9; // CC-ADC Regular Charge Current
  92. CADRDC: byte absolute $EA; // CC-ADC Regular Discharge Current
  93. FCSR: byte absolute $F0; // FET Control and Status Register
  94. CBCR: byte absolute $F1; // Cell Balancing Control Register
  95. BPIMSK: byte absolute $F2; // Battery Protection Interrupt Mask Register
  96. BPIFR: byte absolute $F3; // Battery Protection Interrupt Flag Register
  97. BPSCD: byte absolute $F5; // Battery Protection Short-Circuit Detection Level Register
  98. BPDOCD: byte absolute $F6; // Battery Protection Discharge-Over-current Detection Level Register
  99. BPCOCD: byte absolute $F7; // Battery Protection Charge-Over-current Detection Level Register
  100. BPDHCD: byte absolute $F8; // Battery Protection Discharge-High-current Detection Level Register
  101. BPCHCD: byte absolute $F9; // Battery Protection Charge-High-current Detection Level Register
  102. BPSCTR: byte absolute $FA; // Battery Protection Short-current Timing Register
  103. BPOCTR: byte absolute $FB; // Battery Protection Over-current Timing Register
  104. BPHCTR: byte absolute $FC; // Battery Protection Short-current Timing Register
  105. BPCR: byte absolute $FD; // Battery Protection Control Register
  106. BPPLR: byte absolute $FE; // Battery Protection Parameter Lock Register
  107. const
  108. // Port A Data Register
  109. PA0 = $00;
  110. PA1 = $01;
  111. PA2 = $02;
  112. PA3 = $03;
  113. // Port B Data Register
  114. PB0 = $00;
  115. PB1 = $01;
  116. PB2 = $02;
  117. PB3 = $03;
  118. PB4 = $04;
  119. PB5 = $05;
  120. PB6 = $06;
  121. PB7 = $07;
  122. // Port C Data Register
  123. PC0 = $00;
  124. PC1 = $01;
  125. PC2 = $02;
  126. PC3 = $03;
  127. PC4 = $04;
  128. PC5 = $05;
  129. // Timer/Counter Interrupt Flag register
  130. TOV0 = $00;
  131. OCF0A = $01;
  132. OCF0B = $02;
  133. ICF0 = $03;
  134. // Timer/Counter Interrupt Flag register
  135. TOV1 = $00;
  136. OCF1A = $01;
  137. OCF1B = $02;
  138. ICF1 = $03;
  139. // Oscillator Sampling Interface Control and Status Register
  140. OSIEN = $00;
  141. OSIST = $01;
  142. OSISEL0 = $04;
  143. // Pin Change Interrupt Flag Register
  144. PCIF0 = $00; // Pin Change Interrupt Flags
  145. PCIF1 = $01; // Pin Change Interrupt Flags
  146. // External Interrupt Flag Register
  147. INTF0 = $00; // External Interrupt Flags
  148. INTF1 = $01; // External Interrupt Flags
  149. INTF2 = $02; // External Interrupt Flags
  150. INTF3 = $03; // External Interrupt Flags
  151. // External Interrupt Mask Register
  152. INT0 = $00; // External Interrupt Request 3 Enable
  153. INT1 = $01; // External Interrupt Request 3 Enable
  154. INT2 = $02; // External Interrupt Request 3 Enable
  155. INT3 = $03; // External Interrupt Request 3 Enable
  156. // General Purpose IO Register 0
  157. GPIOR00 = $00; // General Purpose IO bits
  158. GPIOR01 = $01; // General Purpose IO bits
  159. GPIOR02 = $02; // General Purpose IO bits
  160. GPIOR03 = $03; // General Purpose IO bits
  161. GPIOR04 = $04; // General Purpose IO bits
  162. GPIOR05 = $05; // General Purpose IO bits
  163. GPIOR06 = $06; // General Purpose IO bits
  164. GPIOR07 = $07; // General Purpose IO bits
  165. // EEPROM Control Register
  166. EERE = $00;
  167. EEPE = $01;
  168. EEMPE = $02;
  169. EERIE = $03;
  170. EEPM0 = $04;
  171. EEPM1 = $05;
  172. // EEPROM Data Register
  173. EEDR0 = $00; // EEPROM Data bits
  174. EEDR1 = $01; // EEPROM Data bits
  175. EEDR2 = $02; // EEPROM Data bits
  176. EEDR3 = $03; // EEPROM Data bits
  177. EEDR4 = $04; // EEPROM Data bits
  178. EEDR5 = $05; // EEPROM Data bits
  179. EEDR6 = $06; // EEPROM Data bits
  180. EEDR7 = $07; // EEPROM Data bits
  181. // EEPROM Read/Write Access
  182. EEAR0 = $00; // EEPROM Address bits
  183. EEAR1 = $01; // EEPROM Address bits
  184. EEAR2 = $02; // EEPROM Address bits
  185. EEAR3 = $03; // EEPROM Address bits
  186. EEAR4 = $04; // EEPROM Address bits
  187. EEAR5 = $05; // EEPROM Address bits
  188. EEAR6 = $06; // EEPROM Address bits
  189. EEAR7 = $07; // EEPROM Address bits
  190. // General Timer/Counter Control Register
  191. PSRSYNC = $00;
  192. TSM = $07;
  193. // Timer/Counter 0 Control Register A
  194. WGM00 = $00;
  195. ICS0 = $03;
  196. ICES0 = $04;
  197. ICNC0 = $05;
  198. ICEN0 = $06;
  199. TCW0 = $07;
  200. // Timer/Counter0 Control Register B
  201. CS00 = $00;
  202. CS01 = $01;
  203. CS02 = $02;
  204. // Timer Counter 0 Bytes
  205. TCNT00 = $00; // Timer Counter 0 bits
  206. TCNT01 = $01; // Timer Counter 0 bits
  207. TCNT02 = $02; // Timer Counter 0 bits
  208. TCNT03 = $03; // Timer Counter 0 bits
  209. TCNT04 = $04; // Timer Counter 0 bits
  210. TCNT05 = $05; // Timer Counter 0 bits
  211. TCNT06 = $06; // Timer Counter 0 bits
  212. TCNT07 = $07; // Timer Counter 0 bits
  213. // Output Compare Register 0A
  214. OCR0A0 = $00; // Output Compare 0 A bits
  215. OCR0A1 = $01; // Output Compare 0 A bits
  216. OCR0A2 = $02; // Output Compare 0 A bits
  217. OCR0A3 = $03; // Output Compare 0 A bits
  218. OCR0A4 = $04; // Output Compare 0 A bits
  219. OCR0A5 = $05; // Output Compare 0 A bits
  220. OCR0A6 = $06; // Output Compare 0 A bits
  221. OCR0A7 = $07; // Output Compare 0 A bits
  222. // Output Compare Register B
  223. OCR0B0 = $00; // Output Compare 0 B bits
  224. OCR0B1 = $01; // Output Compare 0 B bits
  225. OCR0B2 = $02; // Output Compare 0 B bits
  226. OCR0B3 = $03; // Output Compare 0 B bits
  227. OCR0B4 = $04; // Output Compare 0 B bits
  228. OCR0B5 = $05; // Output Compare 0 B bits
  229. OCR0B6 = $06; // Output Compare 0 B bits
  230. OCR0B7 = $07; // Output Compare 0 B bits
  231. // General Purpose IO Register 1
  232. GPIOR10 = $00; // General Purpose IO bits
  233. GPIOR11 = $01; // General Purpose IO bits
  234. GPIOR12 = $02; // General Purpose IO bits
  235. GPIOR13 = $03; // General Purpose IO bits
  236. GPIOR14 = $04; // General Purpose IO bits
  237. GPIOR15 = $05; // General Purpose IO bits
  238. GPIOR16 = $06; // General Purpose IO bits
  239. GPIOR17 = $07; // General Purpose IO bits
  240. // General Purpose IO Register 2
  241. GPIOR20 = $00; // General Purpose IO bits
  242. GPIOR21 = $01; // General Purpose IO bits
  243. GPIOR22 = $02; // General Purpose IO bits
  244. GPIOR23 = $03; // General Purpose IO bits
  245. GPIOR24 = $04; // General Purpose IO bits
  246. GPIOR25 = $05; // General Purpose IO bits
  247. GPIOR26 = $06; // General Purpose IO bits
  248. GPIOR27 = $07; // General Purpose IO bits
  249. // SPI Control Register
  250. SPR0 = $00; // SPI Clock Rate Selects
  251. SPR1 = $01; // SPI Clock Rate Selects
  252. CPHA = $02;
  253. CPOL = $03;
  254. MSTR = $04;
  255. DORD = $05;
  256. SPE = $06;
  257. SPIE = $07;
  258. // SPI Status Register
  259. SPI2X = $00;
  260. WCOL = $06;
  261. SPIF = $07;
  262. // SPI Data Register
  263. SPDR0 = $00; // SPI Data bits
  264. SPDR1 = $01; // SPI Data bits
  265. SPDR2 = $02; // SPI Data bits
  266. SPDR3 = $03; // SPI Data bits
  267. SPDR4 = $04; // SPI Data bits
  268. SPDR5 = $05; // SPI Data bits
  269. SPDR6 = $06; // SPI Data bits
  270. SPDR7 = $07; // SPI Data bits
  271. // Sleep Mode Control Register
  272. SE = $00;
  273. SM0 = $01; // Sleep Mode Select bits
  274. SM1 = $02; // Sleep Mode Select bits
  275. SM2 = $03; // Sleep Mode Select bits
  276. // MCU Status Register
  277. PORF = $00;
  278. EXTRF = $01;
  279. BODRF = $02;
  280. WDRF = $03;
  281. OCDRF = $04;
  282. // MCU Control Register
  283. IVCE = $00;
  284. IVSEL = $01;
  285. PUD = $04;
  286. CKOE = $05;
  287. // Store Program Memory Control and Status Register
  288. SPMEN = $00;
  289. PGERS = $01;
  290. PGWRT = $02;
  291. LBSET = $03;
  292. RWWSRE = $04;
  293. SIGRD = $05;
  294. RWWSB = $06;
  295. SPMIE = $07;
  296. // Status Register
  297. C = $00;
  298. Z = $01;
  299. N = $02;
  300. V = $03;
  301. S = $04;
  302. H = $05;
  303. T = $06;
  304. I = $07;
  305. // Watchdog Timer Control Register
  306. WDE = $03;
  307. WDCE = $04;
  308. WDP0 = $00; // Watchdog Timer Prescaler Bits
  309. WDP1 = $01; // Watchdog Timer Prescaler Bits
  310. WDP2 = $02; // Watchdog Timer Prescaler Bits
  311. WDP3 = $05; // Watchdog Timer Prescaler Bits
  312. WDIE = $06;
  313. WDIF = $07;
  314. // Clock Prescale Register
  315. CLKPS0 = $00; // Clock Prescaler Select Bits
  316. CLKPS1 = $01; // Clock Prescaler Select Bits
  317. CLKPCE = $07;
  318. // Power Reduction Register 0
  319. PRVADC = $00;
  320. PRTIM0 = $01;
  321. PRTIM1 = $02;
  322. PRSPI = $03;
  323. PRVRM = $05;
  324. PRTWI = $06;
  325. // Fast Oscillator Calibration Value
  326. FCAL0 = $00; // Fast Oscillator Calibration Value
  327. FCAL1 = $01; // Fast Oscillator Calibration Value
  328. FCAL2 = $02; // Fast Oscillator Calibration Value
  329. FCAL3 = $03; // Fast Oscillator Calibration Value
  330. FCAL4 = $04; // Fast Oscillator Calibration Value
  331. FCAL5 = $05; // Fast Oscillator Calibration Value
  332. FCAL6 = $06; // Fast Oscillator Calibration Value
  333. FCAL7 = $07; // Fast Oscillator Calibration Value
  334. // Pin Change Interrupt Control Register
  335. PCIE0 = $00; // Pin Change Interrupt Enables
  336. PCIE1 = $01; // Pin Change Interrupt Enables
  337. // External Interrupt Control Register
  338. ISC00 = $00; // External Interrupt Sense Control 0 Bits
  339. ISC01 = $01; // External Interrupt Sense Control 0 Bits
  340. ISC10 = $02; // External Interrupt Sense Control 1 Bits
  341. ISC11 = $03; // External Interrupt Sense Control 1 Bits
  342. ISC20 = $04; // External Interrupt Sense Control 2 Bits
  343. ISC21 = $05; // External Interrupt Sense Control 2 Bits
  344. ISC30 = $06; // External Interrupt Sense Control 3 Bits
  345. ISC31 = $07; // External Interrupt Sense Control 3 Bits
  346. // Pin Change Enable Mask Register 1
  347. PCINT4 = $00; // Pin Change Enable Mask
  348. PCINT5 = $01; // Pin Change Enable Mask
  349. PCINT6 = $02; // Pin Change Enable Mask
  350. PCINT7 = $03; // Pin Change Enable Mask
  351. PCINT8 = $04; // Pin Change Enable Mask
  352. PCINT9 = $05; // Pin Change Enable Mask
  353. PCINT10 = $06; // Pin Change Enable Mask
  354. PCINT11 = $07; // Pin Change Enable Mask
  355. // Timer/Counter Interrupt Mask Register
  356. TOIE0 = $00;
  357. OCIE0A = $01;
  358. OCIE0B = $02;
  359. ICIE0 = $03;
  360. // Timer/Counter Interrupt Mask Register
  361. TOIE1 = $00;
  362. OCIE1A = $01;
  363. OCIE1B = $02;
  364. ICIE1 = $03;
  365. // VADC Data Register Bytes
  366. VADC0 = $00; // VADC Data bits
  367. VADC1 = $01; // VADC Data bits
  368. VADC2 = $02; // VADC Data bits
  369. VADC3 = $03; // VADC Data bits
  370. VADC4 = $04; // VADC Data bits
  371. VADC5 = $05; // VADC Data bits
  372. VADC6 = $06; // VADC Data bits
  373. VADC7 = $07; // VADC Data bits
  374. // The VADC Control and Status register
  375. VADCCIE = $00;
  376. VADCCIF = $01;
  377. VADSC = $02;
  378. VADEN = $03;
  379. // The VADC multiplexer Selection Register
  380. VADMUX0 = $00; // Analog Channel and Gain Selection Bits
  381. VADMUX1 = $01; // Analog Channel and Gain Selection Bits
  382. VADMUX2 = $02; // Analog Channel and Gain Selection Bits
  383. VADMUX3 = $03; // Analog Channel and Gain Selection Bits
  384. // Digital Input Disable Register
  385. PA0DID = $00;
  386. PA1DID = $01;
  387. // Timer/Counter 1 Control Register A
  388. WGM10 = $00;
  389. ICS1 = $03;
  390. ICES1 = $04;
  391. ICNC1 = $05;
  392. ICEN1 = $06;
  393. TCW1 = $07;
  394. // Timer/Counter1 Control Register B
  395. CS10 = $00; // Clock Select1 bis
  396. CS11 = $01; // Clock Select1 bis
  397. CS12 = $02; // Clock Select1 bis
  398. // Timer Counter 1 Bytes
  399. TCNT10 = $00; // Timer Counter 1 bits
  400. TCNT11 = $01; // Timer Counter 1 bits
  401. TCNT12 = $02; // Timer Counter 1 bits
  402. TCNT13 = $03; // Timer Counter 1 bits
  403. TCNT14 = $04; // Timer Counter 1 bits
  404. TCNT15 = $05; // Timer Counter 1 bits
  405. TCNT16 = $06; // Timer Counter 1 bits
  406. TCNT17 = $07; // Timer Counter 1 bits
  407. // Output Compare Register 1A
  408. OCR1A0 = $00; // Output Compare 1 A bits
  409. OCR1A1 = $01; // Output Compare 1 A bits
  410. OCR1A2 = $02; // Output Compare 1 A bits
  411. OCR1A3 = $03; // Output Compare 1 A bits
  412. OCR1A4 = $04; // Output Compare 1 A bits
  413. OCR1A5 = $05; // Output Compare 1 A bits
  414. OCR1A6 = $06; // Output Compare 1 A bits
  415. OCR1A7 = $07; // Output Compare 1 A bits
  416. // Output Compare Register B
  417. OCR1B0 = $00; // Output Compare 1 B bits
  418. OCR1B1 = $01; // Output Compare 1 B bits
  419. OCR1B2 = $02; // Output Compare 1 B bits
  420. OCR1B3 = $03; // Output Compare 1 B bits
  421. OCR1B4 = $04; // Output Compare 1 B bits
  422. OCR1B5 = $05; // Output Compare 1 B bits
  423. OCR1B6 = $06; // Output Compare 1 B bits
  424. OCR1B7 = $07; // Output Compare 1 B bits
  425. // TWI Bit Rate register
  426. TWBR0 = $00; // TWI Bit Rate bits
  427. TWBR1 = $01; // TWI Bit Rate bits
  428. TWBR2 = $02; // TWI Bit Rate bits
  429. TWBR3 = $03; // TWI Bit Rate bits
  430. TWBR4 = $04; // TWI Bit Rate bits
  431. TWBR5 = $05; // TWI Bit Rate bits
  432. TWBR6 = $06; // TWI Bit Rate bits
  433. TWBR7 = $07; // TWI Bit Rate bits
  434. // TWI Status Register
  435. TWPS0 = $00; // TWI Prescaler
  436. TWPS1 = $01; // TWI Prescaler
  437. TWS3 = $03; // TWI Status
  438. TWS4 = $04; // TWI Status
  439. TWS5 = $05; // TWI Status
  440. TWS6 = $06; // TWI Status
  441. TWS7 = $07; // TWI Status
  442. // TWI (Slave) Address register
  443. TWGCE = $00;
  444. TWA0 = $01; // TWI (Slave) Address register Bits
  445. TWA1 = $02; // TWI (Slave) Address register Bits
  446. TWA2 = $03; // TWI (Slave) Address register Bits
  447. TWA3 = $04; // TWI (Slave) Address register Bits
  448. TWA4 = $05; // TWI (Slave) Address register Bits
  449. TWA5 = $06; // TWI (Slave) Address register Bits
  450. TWA6 = $07; // TWI (Slave) Address register Bits
  451. // TWI Data register
  452. TWD0 = $00; // TWI Data Bits
  453. TWD1 = $01; // TWI Data Bits
  454. TWD2 = $02; // TWI Data Bits
  455. TWD3 = $03; // TWI Data Bits
  456. TWD4 = $04; // TWI Data Bits
  457. TWD5 = $05; // TWI Data Bits
  458. TWD6 = $06; // TWI Data Bits
  459. TWD7 = $07; // TWI Data Bits
  460. // TWI Control Register
  461. TWIE = $00;
  462. TWEN = $02;
  463. TWWC = $03;
  464. TWSTO = $04;
  465. TWSTA = $05;
  466. TWEA = $06;
  467. TWINT = $07;
  468. // TWI (Slave) Address Mask Register
  469. TWAM0 = $01;
  470. TWAM1 = $02;
  471. TWAM2 = $03;
  472. TWAM3 = $04;
  473. TWAM4 = $05;
  474. TWAM5 = $06;
  475. TWAM6 = $07;
  476. // TWI Bus Control and Status Register
  477. TWBCIP = $00;
  478. TWBDT0 = $01; // TWI Bus Disconnect Time-out Period
  479. TWBDT1 = $02; // TWI Bus Disconnect Time-out Period
  480. TWBCIE = $06;
  481. TWBCIF = $07;
  482. // Regulator Operating Condition Register
  483. ROCWIE = $00;
  484. ROCWIF = $01;
  485. ROCD = $04;
  486. ROCS = $07;
  487. // Bandgap Calibration Register
  488. BGCC0 = $00; // BG Calibration of PTAT Current Bits
  489. BGCC1 = $01; // BG Calibration of PTAT Current Bits
  490. BGCC2 = $02; // BG Calibration of PTAT Current Bits
  491. BGCC3 = $03; // BG Calibration of PTAT Current Bits
  492. BGCC4 = $04; // BG Calibration of PTAT Current Bits
  493. BGCC5 = $05; // BG Calibration of PTAT Current Bits
  494. // Bandgap Calibration of Resistor Ladder
  495. BGCR0 = $00; // Bandgap Calibration of Resistor Ladder Bits
  496. BGCR1 = $01; // Bandgap Calibration of Resistor Ladder Bits
  497. BGCR2 = $02; // Bandgap Calibration of Resistor Ladder Bits
  498. BGCR3 = $03; // Bandgap Calibration of Resistor Ladder Bits
  499. BGCR4 = $04; // Bandgap Calibration of Resistor Ladder Bits
  500. BGCR5 = $05; // Bandgap Calibration of Resistor Ladder Bits
  501. BGCR6 = $06; // Bandgap Calibration of Resistor Ladder Bits
  502. BGCR7 = $07; // Bandgap Calibration of Resistor Ladder Bits
  503. // Bandgap Control and Status Register
  504. BGSCDIE = $00;
  505. BGSCDIF = $01;
  506. BGSCDE = $04;
  507. BGD = $05;
  508. // Charger Detect Control and Status Register
  509. CHGDIE = $00;
  510. CHGDIF = $01;
  511. CHGDISC0 = $02; // Charger Detect Interrupt Sense Control
  512. CHGDISC1 = $03; // Charger Detect Interrupt Sense Control
  513. BATTPVL = $04;
  514. // ADC Accumulate Current
  515. CADAC08 = $00; // ADC accumulate current bits
  516. CADAC09 = $01; // ADC accumulate current bits
  517. // ADC Accumulate Current
  518. CADAC24 = $00; // ADC accumulate current bits
  519. CADAC25 = $01; // ADC accumulate current bits
  520. CADAC26 = $02; // ADC accumulate current bits
  521. CADAC27 = $03; // ADC accumulate current bits
  522. CADAC28 = $04; // ADC accumulate current bits
  523. CADAC29 = $05; // ADC accumulate current bits
  524. CADAC30 = $06; // ADC accumulate current bits
  525. CADAC31 = $07; // ADC accumulate current bits
  526. // CC-ADC Instantaneous Current
  527. CADIC0 = $00; // CC-ADC Instantaneous Current
  528. CADIC1 = $01; // CC-ADC Instantaneous Current
  529. CADIC2 = $02; // CC-ADC Instantaneous Current
  530. CADIC3 = $03; // CC-ADC Instantaneous Current
  531. CADIC4 = $04; // CC-ADC Instantaneous Current
  532. CADIC5 = $05; // CC-ADC Instantaneous Current
  533. CADIC6 = $06; // CC-ADC Instantaneous Current
  534. CADIC7 = $07; // CC-ADC Instantaneous Current
  535. // CC-ADC Control and Status Register A
  536. CADSE = $00;
  537. CADSI0 = $01; // The CADSI bits determine the current sampling interval for the Regular Current detection in Power-down mode. The actual settings remain to be determined.
  538. CADSI1 = $02; // The CADSI bits determine the current sampling interval for the Regular Current detection in Power-down mode. The actual settings remain to be determined.
  539. CADAS0 = $03; // CC_ADC Accumulate Current Select Bits
  540. CADAS1 = $04; // CC_ADC Accumulate Current Select Bits
  541. CADUB = $05;
  542. CADPOL = $06;
  543. CADEN = $07;
  544. // CC-ADC Control and Status Register B
  545. CADICIF = $00;
  546. CADRCIF = $01;
  547. CADACIF = $02;
  548. CADICIE = $04;
  549. CADRCIE = $05;
  550. CADACIE = $06;
  551. // CC-ADC Control and Status Register C
  552. CADVSE = $00;
  553. // CC-ADC Regular Charge Current
  554. CADRCC0 = $00; // CC-ADC Regular Charge Current
  555. CADRCC1 = $01; // CC-ADC Regular Charge Current
  556. CADRCC2 = $02; // CC-ADC Regular Charge Current
  557. CADRCC3 = $03; // CC-ADC Regular Charge Current
  558. CADRCC4 = $04; // CC-ADC Regular Charge Current
  559. CADRCC5 = $05; // CC-ADC Regular Charge Current
  560. CADRCC6 = $06; // CC-ADC Regular Charge Current
  561. CADRCC7 = $07; // CC-ADC Regular Charge Current
  562. // CC-ADC Regular Discharge Current
  563. CADRDC0 = $00; // CC-ADC Regular Discharge Current
  564. CADRDC1 = $01; // CC-ADC Regular Discharge Current
  565. CADRDC2 = $02; // CC-ADC Regular Discharge Current
  566. CADRDC3 = $03; // CC-ADC Regular Discharge Current
  567. CADRDC4 = $04; // CC-ADC Regular Discharge Current
  568. CADRDC5 = $05; // CC-ADC Regular Discharge Current
  569. CADRDC6 = $06; // CC-ADC Regular Discharge Current
  570. CADRDC7 = $07; // CC-ADC Regular Discharge Current
  571. // FET Control and Status Register
  572. CFE = $00;
  573. DFE = $01;
  574. CPS = $02;
  575. DUVRD = $03;
  576. // Cell Balancing Control Register
  577. CBE1 = $00; // Cell Balancing Enables
  578. CBE2 = $01; // Cell Balancing Enables
  579. CBE3 = $02; // Cell Balancing Enables
  580. CBE4 = $03; // Cell Balancing Enables
  581. // Battery Protection Interrupt Mask Register
  582. CHCIE = $00;
  583. DHCIE = $01;
  584. COCIE = $02;
  585. DOCIE = $03;
  586. SCIE = $04;
  587. // Battery Protection Interrupt Flag Register
  588. CHCIF = $00;
  589. DHCIF = $01;
  590. COCIF = $02;
  591. DOCIF = $03;
  592. SCIF = $04;
  593. // Battery Protection Short-Circuit Detection Level Register
  594. SCDL0 = $00; // Battery Protection Short-Circuit Detection Level Register bits
  595. SCDL1 = $01; // Battery Protection Short-Circuit Detection Level Register bits
  596. SCDL2 = $02; // Battery Protection Short-Circuit Detection Level Register bits
  597. SCDL3 = $03; // Battery Protection Short-Circuit Detection Level Register bits
  598. SCDL4 = $04; // Battery Protection Short-Circuit Detection Level Register bits
  599. SCDL5 = $05; // Battery Protection Short-Circuit Detection Level Register bits
  600. SCDL6 = $06; // Battery Protection Short-Circuit Detection Level Register bits
  601. SCDL7 = $07; // Battery Protection Short-Circuit Detection Level Register bits
  602. // Battery Protection Discharge-Over-current Detection Level Register
  603. DOCDL0 = $00; // Battery Protection Discharge-Over-current Detection Level bits
  604. DOCDL1 = $01; // Battery Protection Discharge-Over-current Detection Level bits
  605. DOCDL2 = $02; // Battery Protection Discharge-Over-current Detection Level bits
  606. DOCDL3 = $03; // Battery Protection Discharge-Over-current Detection Level bits
  607. DOCDL4 = $04; // Battery Protection Discharge-Over-current Detection Level bits
  608. DOCDL5 = $05; // Battery Protection Discharge-Over-current Detection Level bits
  609. DOCDL6 = $06; // Battery Protection Discharge-Over-current Detection Level bits
  610. DOCDL7 = $07; // Battery Protection Discharge-Over-current Detection Level bits
  611. // Battery Protection Charge-Over-current Detection Level Register
  612. COCDL0 = $00; // Battery Protection Charge-Over-current Detection Level bits
  613. COCDL1 = $01; // Battery Protection Charge-Over-current Detection Level bits
  614. COCDL2 = $02; // Battery Protection Charge-Over-current Detection Level bits
  615. COCDL3 = $03; // Battery Protection Charge-Over-current Detection Level bits
  616. COCDL4 = $04; // Battery Protection Charge-Over-current Detection Level bits
  617. COCDL5 = $05; // Battery Protection Charge-Over-current Detection Level bits
  618. COCDL6 = $06; // Battery Protection Charge-Over-current Detection Level bits
  619. COCDL7 = $07; // Battery Protection Charge-Over-current Detection Level bits
  620. // Battery Protection Discharge-High-current Detection Level Register
  621. DHCDL0 = $00; // Battery Protection Discharge-High-current Detection Level bits
  622. DHCDL1 = $01; // Battery Protection Discharge-High-current Detection Level bits
  623. DHCDL2 = $02; // Battery Protection Discharge-High-current Detection Level bits
  624. DHCDL3 = $03; // Battery Protection Discharge-High-current Detection Level bits
  625. DHCDL4 = $04; // Battery Protection Discharge-High-current Detection Level bits
  626. DHCDL5 = $05; // Battery Protection Discharge-High-current Detection Level bits
  627. DHCDL6 = $06; // Battery Protection Discharge-High-current Detection Level bits
  628. DHCDL7 = $07; // Battery Protection Discharge-High-current Detection Level bits
  629. // Battery Protection Charge-High-current Detection Level Register
  630. CHCDL0 = $00; // Battery Protection Charge-High-current Detection Level bits
  631. CHCDL1 = $01; // Battery Protection Charge-High-current Detection Level bits
  632. CHCDL2 = $02; // Battery Protection Charge-High-current Detection Level bits
  633. CHCDL3 = $03; // Battery Protection Charge-High-current Detection Level bits
  634. CHCDL4 = $04; // Battery Protection Charge-High-current Detection Level bits
  635. CHCDL5 = $05; // Battery Protection Charge-High-current Detection Level bits
  636. CHCDL6 = $06; // Battery Protection Charge-High-current Detection Level bits
  637. CHCDL7 = $07; // Battery Protection Charge-High-current Detection Level bits
  638. // Battery Protection Short-current Timing Register
  639. SCPT0 = $00; // Battery Protection Short-current Timing bits
  640. SCPT1 = $01; // Battery Protection Short-current Timing bits
  641. SCPT2 = $02; // Battery Protection Short-current Timing bits
  642. SCPT3 = $03; // Battery Protection Short-current Timing bits
  643. SCPT4 = $04; // Battery Protection Short-current Timing bits
  644. SCPT5 = $05; // Battery Protection Short-current Timing bits
  645. SCPT6 = $06; // Battery Protection Short-current Timing bits
  646. // Battery Protection Over-current Timing Register
  647. OCPT0 = $00; // Battery Protection Over-current Timing bits
  648. OCPT1 = $01; // Battery Protection Over-current Timing bits
  649. OCPT2 = $02; // Battery Protection Over-current Timing bits
  650. OCPT3 = $03; // Battery Protection Over-current Timing bits
  651. OCPT4 = $04; // Battery Protection Over-current Timing bits
  652. OCPT5 = $05; // Battery Protection Over-current Timing bits
  653. // Battery Protection Short-current Timing Register
  654. HCPT0 = $00; // Battery Protection Short-current Timing bits
  655. HCPT1 = $01; // Battery Protection Short-current Timing bits
  656. HCPT2 = $02; // Battery Protection Short-current Timing bits
  657. HCPT3 = $03; // Battery Protection Short-current Timing bits
  658. HCPT4 = $04; // Battery Protection Short-current Timing bits
  659. HCPT5 = $05; // Battery Protection Short-current Timing bits
  660. // Battery Protection Control Register
  661. CHCD = $00;
  662. DHCD = $01;
  663. COCD = $02;
  664. DOCD = $03;
  665. SCD = $04;
  666. EPID = $05;
  667. // Battery Protection Parameter Lock Register
  668. BPPL = $00;
  669. BPPLE = $01;
  670. implementation
  671. {$i avrcommon.inc}
  672. procedure BPINT_ISR; external name 'BPINT_ISR'; // Interrupt 1 Battery Protection Interrupt
  673. procedure VREGMON_ISR; external name 'VREGMON_ISR'; // Interrupt 2 Voltage regulator monitor interrupt
  674. procedure INT0_ISR; external name 'INT0_ISR'; // Interrupt 3 External Interrupt Request 0
  675. procedure INT1_ISR; external name 'INT1_ISR'; // Interrupt 4 External Interrupt Request 1
  676. procedure INT2_ISR; external name 'INT2_ISR'; // Interrupt 5 External Interrupt Request 2
  677. procedure INT3_ISR; external name 'INT3_ISR'; // Interrupt 6 External Interrupt Request 3
  678. procedure PCINT0_ISR; external name 'PCINT0_ISR'; // Interrupt 7 Pin Change Interrupt 0
  679. procedure PCINT1_ISR; external name 'PCINT1_ISR'; // Interrupt 8 Pin Change Interrupt 1
  680. procedure WDT_ISR; external name 'WDT_ISR'; // Interrupt 9 Watchdog Timeout Interrupt
  681. procedure BGSCD_ISR; external name 'BGSCD_ISR'; // Interrupt 10 Bandgap Buffer Short Circuit Detected
  682. procedure CHDET_ISR; external name 'CHDET_ISR'; // Interrupt 11 Charger Detect
  683. procedure TIMER1_IC_ISR; external name 'TIMER1_IC_ISR'; // Interrupt 12 Timer 1 Input capture
  684. procedure TIMER1_COMPA_ISR; external name 'TIMER1_COMPA_ISR'; // Interrupt 13 Timer 1 Compare Match A
  685. procedure TIMER1_COMPB_ISR; external name 'TIMER1_COMPB_ISR'; // Interrupt 14 Timer 1 Compare Match B
  686. procedure TIMER1_OVF_ISR; external name 'TIMER1_OVF_ISR'; // Interrupt 15 Timer 1 overflow
  687. procedure TIMER0_IC_ISR; external name 'TIMER0_IC_ISR'; // Interrupt 16 Timer 0 Input Capture
  688. procedure TIMER0_COMPA_ISR; external name 'TIMER0_COMPA_ISR'; // Interrupt 17 Timer 0 Comapre Match A
  689. procedure TIMER0_COMPB_ISR; external name 'TIMER0_COMPB_ISR'; // Interrupt 18 Timer 0 Compare Match B
  690. procedure TIMER0_OVF_ISR; external name 'TIMER0_OVF_ISR'; // Interrupt 19 Timer 0 Overflow
  691. procedure TWIBUSCD_ISR; external name 'TWIBUSCD_ISR'; // Interrupt 20 Two-Wire Bus Connect/Disconnect
  692. procedure TWI_ISR; external name 'TWI_ISR'; // Interrupt 21 Two-Wire Serial Interface
  693. procedure SPI_STC_ISR; external name 'SPI_STC_ISR'; // Interrupt 22 SPI Serial transfer complete
  694. procedure VADC_ISR; external name 'VADC_ISR'; // Interrupt 23 Voltage ADC Conversion Complete
  695. procedure CCADC_CONV_ISR; external name 'CCADC_CONV_ISR'; // Interrupt 24 Coulomb Counter ADC Conversion Complete
  696. procedure CCADC_REG_CUR_ISR; external name 'CCADC_REG_CUR_ISR'; // Interrupt 25 Coloumb Counter ADC Regular Current
  697. procedure CCADC_ACC_ISR; external name 'CCADC_ACC_ISR'; // Interrupt 26 Coloumb Counter ADC Accumulator
  698. procedure EE_READY_ISR; external name 'EE_READY_ISR'; // Interrupt 27 EEPROM Ready
  699. procedure SPM_ISR; external name 'SPM_ISR'; // Interrupt 28 SPM Ready
  700. procedure _FPC_start; assembler; nostackframe;
  701. label
  702. _start;
  703. asm
  704. .init
  705. .globl _start
  706. jmp _start
  707. jmp BPINT_ISR
  708. jmp VREGMON_ISR
  709. jmp INT0_ISR
  710. jmp INT1_ISR
  711. jmp INT2_ISR
  712. jmp INT3_ISR
  713. jmp PCINT0_ISR
  714. jmp PCINT1_ISR
  715. jmp WDT_ISR
  716. jmp BGSCD_ISR
  717. jmp CHDET_ISR
  718. jmp TIMER1_IC_ISR
  719. jmp TIMER1_COMPA_ISR
  720. jmp TIMER1_COMPB_ISR
  721. jmp TIMER1_OVF_ISR
  722. jmp TIMER0_IC_ISR
  723. jmp TIMER0_COMPA_ISR
  724. jmp TIMER0_COMPB_ISR
  725. jmp TIMER0_OVF_ISR
  726. jmp TWIBUSCD_ISR
  727. jmp TWI_ISR
  728. jmp SPI_STC_ISR
  729. jmp VADC_ISR
  730. jmp CCADC_CONV_ISR
  731. jmp CCADC_REG_CUR_ISR
  732. jmp CCADC_ACC_ISR
  733. jmp EE_READY_ISR
  734. jmp SPM_ISR
  735. {$i start.inc}
  736. .weak BPINT_ISR
  737. .weak VREGMON_ISR
  738. .weak INT0_ISR
  739. .weak INT1_ISR
  740. .weak INT2_ISR
  741. .weak INT3_ISR
  742. .weak PCINT0_ISR
  743. .weak PCINT1_ISR
  744. .weak WDT_ISR
  745. .weak BGSCD_ISR
  746. .weak CHDET_ISR
  747. .weak TIMER1_IC_ISR
  748. .weak TIMER1_COMPA_ISR
  749. .weak TIMER1_COMPB_ISR
  750. .weak TIMER1_OVF_ISR
  751. .weak TIMER0_IC_ISR
  752. .weak TIMER0_COMPA_ISR
  753. .weak TIMER0_COMPB_ISR
  754. .weak TIMER0_OVF_ISR
  755. .weak TWIBUSCD_ISR
  756. .weak TWI_ISR
  757. .weak SPI_STC_ISR
  758. .weak VADC_ISR
  759. .weak CCADC_CONV_ISR
  760. .weak CCADC_REG_CUR_ISR
  761. .weak CCADC_ACC_ISR
  762. .weak EE_READY_ISR
  763. .weak SPM_ISR
  764. .set BPINT_ISR, Default_IRQ_handler
  765. .set VREGMON_ISR, Default_IRQ_handler
  766. .set INT0_ISR, Default_IRQ_handler
  767. .set INT1_ISR, Default_IRQ_handler
  768. .set INT2_ISR, Default_IRQ_handler
  769. .set INT3_ISR, Default_IRQ_handler
  770. .set PCINT0_ISR, Default_IRQ_handler
  771. .set PCINT1_ISR, Default_IRQ_handler
  772. .set WDT_ISR, Default_IRQ_handler
  773. .set BGSCD_ISR, Default_IRQ_handler
  774. .set CHDET_ISR, Default_IRQ_handler
  775. .set TIMER1_IC_ISR, Default_IRQ_handler
  776. .set TIMER1_COMPA_ISR, Default_IRQ_handler
  777. .set TIMER1_COMPB_ISR, Default_IRQ_handler
  778. .set TIMER1_OVF_ISR, Default_IRQ_handler
  779. .set TIMER0_IC_ISR, Default_IRQ_handler
  780. .set TIMER0_COMPA_ISR, Default_IRQ_handler
  781. .set TIMER0_COMPB_ISR, Default_IRQ_handler
  782. .set TIMER0_OVF_ISR, Default_IRQ_handler
  783. .set TWIBUSCD_ISR, Default_IRQ_handler
  784. .set TWI_ISR, Default_IRQ_handler
  785. .set SPI_STC_ISR, Default_IRQ_handler
  786. .set VADC_ISR, Default_IRQ_handler
  787. .set CCADC_CONV_ISR, Default_IRQ_handler
  788. .set CCADC_REG_CUR_ISR, Default_IRQ_handler
  789. .set CCADC_ACC_ISR, Default_IRQ_handler
  790. .set EE_READY_ISR, Default_IRQ_handler
  791. .set SPM_ISR, Default_IRQ_handler
  792. end;
  793. end.