atmega16hvbrevb.pp 33 KB

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