Advertisement
Guest User

Untitled

a guest
Mar 13th, 2014
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.37 KB | None | 0 0
  1. ' Emulation eines DS2501 aus Dell Notebook netzteilen
  2.  
  3.  
  4. ' Entwicklung basiert auf folgenden Quellen :
  5.  
  6. ' Dallas DS 2501/02 Datasheet
  7. ' Webseite Wolfgang Pöllinger -> www.wpö.de
  8. ' Webseite http://www.howtofixcomputers.com/forums/dell/dell-pa-10-ac-adapter-center-pin-108608.html
  9. ' Webseite http://www.laptop-junction.com/toast/content/inside-dell-ac-power-adapter-mystery-revealed
  10. ' Webseite http://www.ringwelt.de/computer/pc/dell-d600-mit-12v-netzteil.html
  11. ' Webseite http://bascom.at.ua/publ/1-1-0-1
  12.  
  13.  
  14. ' Attiny 13 V --- UB = 3,6 Volt -- 78L05 + 2x 1n4148 an dessen Ausgang -- gespeist aus 19 Volt von Dell
  15. ' 1Wire an Pin2 = PB3
  16.  
  17. '
  18. '
  19. '
  20. '
  21. ' + VCC +3,6
  22. ' +
  23. ' |
  24. ' .-.
  25. ' | | 4k7
  26. ' | |
  27. ' '-'
  28. ' | ___
  29. ' Dell 1 Wire o--o|___|---------> PB3
  30.  
  31. ' 220R
  32. '
  33. '
  34. '
  35.  
  36. ' (created by AACircuit v1.28.6 beta 04/19/05 www.tech-chat.de)
  37.  
  38.  
  39.  
  40.  
  41. $crystal = 9600000
  42. $regfile = "attiny13.dat"
  43.  
  44.  
  45. $hwstack = 32
  46. $swstack = 8
  47. $framesize = 16
  48.  
  49.  
  50. Dim Incommand(2) As Byte
  51. Dim Bytedat As Byte
  52. Dim Bytedatbuffer As Byte
  53.  
  54. Dim I As Byte
  55. Dim B As Byte
  56. Dim Crc As Byte
  57. Dim Bufstart As Byte
  58.  
  59.  
  60.  
  61. ' Commands
  62.  
  63. Const Skip_rom = &HCC
  64. Const Read_rom = &H33
  65. Const Read_mem = &HF0
  66.  
  67. ' we use port b .3
  68. Const Dqpin = 3
  69. Const Ipin = 0 ' value in DDRB for input
  70. Const Opin = 1 ' value in DDRB for output
  71. Dq Alias Pinb.dqpin
  72.  
  73.  
  74.  
  75. ' Timings
  76.  
  77. Const Owpresent = 150
  78. Const Owpause = 50
  79. Const Owstrobe = 15
  80. Const Owdata = 25
  81.  
  82. ' Timer Delays
  83.  
  84. Const T1reset = 60
  85. Const Timeout = 120
  86.  
  87. ' *********************** TIMER and ISR
  88. Config Timer0 = Timer , Prescale = 64
  89. Stop Timer0
  90. Enable Timer0
  91. On Timer0 Isr Nosave
  92. Timer_t0 Alias Tcnt0
  93. '***************************************
  94.  
  95.  
  96.  
  97.  
  98. Mainloop:
  99. Waitreset:
  100.  
  101. Disable Interrupts
  102. Timer_t0 = 0
  103.  
  104. Waitfall:
  105.  
  106. L1:
  107. sbis pinb, DqPin
  108. rjmp L1
  109. L2:
  110. sbic pinb, DqPin
  111. rjmp L2
  112.  
  113. Start Timer0
  114.  
  115. Rwaitrise:
  116.  
  117. L01:
  118. sbic pinb, DqPin
  119. rjmp L01
  120. L02:
  121. sbis pinb, DqPin
  122. rjmp L02
  123.  
  124. Stop Timer0
  125.  
  126. If Timer_t0 < T1reset Then Goto Waitreset
  127. If Timer_t0 > Timeout Then Goto Waitreset
  128.  
  129.  
  130. Sendpresense:
  131. Waitus Owpause
  132.  
  133. Ddrb.dqpin = Opin
  134.  
  135. Waitus Owpresent
  136. Ddrb.dqpin = Ipin
  137. Timer_t0 = 0
  138. Enable Interrupts
  139.  
  140. Readb:
  141.  
  142. Gosub Readbyte
  143.  
  144. Readb1:
  145.  
  146. If Bytedat = Read_rom Then Goto Readrom
  147.  
  148.  
  149. If Bytedat = Skip_rom Then
  150. Crc = 0
  151. For B = 1 To 2
  152. Gosub Readbyte
  153. Incommand(b) = Bytedat
  154. Bytedatbuffer = Crc Xor Incommand(b)
  155.  
  156. Crc = Crc8(bytedatbuffer , 1)
  157. Next B
  158.  
  159.  
  160. Gosub Readbyte ' empty read for high adress
  161. 'Bytedatbuffer = Crc Xor 00
  162. Bytedat = Crc8(crc , 1)
  163. Gosub Sendbyte
  164.  
  165.  
  166.  
  167. If Incommand(1) = Read_mem Then Goto Readmem
  168.  
  169.  
  170.  
  171. End If
  172. Goto Waitreset
  173. End
  174.  
  175. Readrom:
  176. For B = 0 To 7
  177. Bytedat = Lookup(b , Rom)
  178. Gosub Sendbyte
  179. Next B
  180. Goto Waitreset
  181. '----------------------------------
  182. '================================
  183. Readbyte:
  184. For I = 0 To 7
  185.  
  186. L11:
  187. sbis pinb, DqPin
  188. rjmp L11
  189. L12:
  190. sbic pinb, DqPin
  191. rjmp L12
  192. Timer_t0 = 256 - T1reset
  193. Start Timer0
  194.  
  195. Rotate Bytedat , Right
  196. Waitus Owstrobe
  197.  
  198.  
  199. Bytedat.7 = Dq
  200.  
  201. Next I
  202. Stop Timer0
  203. Return
  204. '----------------------------------
  205. Sendbyte:
  206. Bytedatbuffer = Bytedat
  207. For I = 0 To 7
  208.  
  209. L21:
  210. sbis pinb, DqPin
  211. rjmp L21
  212. L22:
  213. sbic pinb, DqPin
  214. rjmp L22
  215. Timer_t0 = 256 - T1reset
  216. Start Timer0
  217.  
  218. If Bytedat.0 = 0 Then Ddrb.dqpin = Opin
  219. Waitus Owdata
  220. Ddrb.dqpin = Ipin
  221.  
  222. Rotate Bytedat , Right
  223.  
  224. Next I
  225. Bytedat = Bytedatbuffer
  226. Stop Timer0
  227. Return
  228. '-----------------------------------
  229.  
  230. Readmem:
  231. Crc = 0
  232. Bufstart = Incommand(2)
  233.  
  234. For B = Bufstart To 63
  235. Bytedat = Lookup(b , Mem1)
  236. 'Print Hex(bytedat)
  237. Bytedatbuffer = Crc Xor Bytedat
  238.  
  239. Crc = Crc8(bytedatbuffer , 1)
  240. Gosub Sendbyte
  241. Next B
  242.  
  243. Bytedat = Crc
  244.  
  245. Gosub Sendbyte
  246.  
  247. Goto Waitreset
  248.  
  249.  
  250. ' *********************** isr
  251. Isr:
  252.  
  253. If Dq = 0 Then ' Das ist Strange mit den Goto aus der Isr rauszugehen.
  254. 'aber es läuft
  255. Timer_t0 = T1reset
  256.  
  257. Goto Rwaitrise
  258. Else
  259. Goto Waitreset
  260. End If
  261.  
  262. Return
  263.  
  264. '******************************
  265.  
  266.  
  267.  
  268.  
  269.  
  270. '*************** ROM **************************
  271. Rom:
  272. Data &H11 , &HB4 , &H91 , &H2F , &H05 , &H00 , &H00 , &HB8
  273.  
  274.  
  275.  
  276. '*************** mem 1 **************************
  277. ' Settings für 90 Watt Netzteil
  278.  
  279. Mem1:
  280.  
  281. Data &H44 , &H45 , &H4C , &H4C , &H30 , &H30 , &H41 , &H43
  282. Data &H30 , &H39 , &H30 , &H31 , &H39 , &H35 , &H30 , &H34
  283. Data &H36 , &H43 , &H4E , &H30 , &H43 , &H38 , &H30 , &H32
  284. Data &H33 , &H34 , &H38 , &H36 , &H36 , &H31 , &H36 , &H31
  285. Data &H52 , &H32 , &H33 , &H48 , &H38 , &H41 , &H30 , &H33
  286. Data &H4D , &H7C , &HFF , &HFF , &HFF , &HFF , &HFF , &HFF
  287. Data &HFF , &HFF , &HFF , &HFF , &HFF , &HFF , &HFF , &HFF
  288. Data &HFF , &HFF , &HFF , &HFF , &HFF , &HFF , &HFF , &HFF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement