Download: File: X:\USERS\IGOR\DOC\WORD\Atmel\USB to RS232 Application Note\Firmware\USBtoRS232_ATmega8\AVR Studio 4 project\USBtoRS232.asm 1.2.2004

1 ;*************************************************************************** 2 ;* USBSTACKFORTHEAVRFAMILY3;* 4 ;* File Name :"USBtoRS232.asm" 5 ;* Title :AVR309:USB to UART protocol converter 6 ;* Date :01.02.2004 7 ;* Version :2.8 8 ;* Target MCU :ATmega8 9 ;* AUTHOR :Ing. Igor Cesko 10 ;* Slovakia 11 ;* email is hidden 12 ;* http://www.cesko.host.sk 13 ;* 14 ;* DESCRIPTION: 15 ;* USB protocol implementation into MCU with noUSB interface: 16 ;* Device: 17 ;* Universal USB interface (3x8-bit I/O port + RS232 serial line + EEPROM) 18 ;* + added RS232 FIFO buffer 19 ;* 20 ;* The timing is adap...
Author: Zoble1980 Shared: 8/19/19
Downloads: 539 Views: 1352

Content

1 ;*************************************************************************** 2 ;* USBSTACKFORTHEAVRFAMILY3;* 4 ;* File Name :"USBtoRS232.asm" 5 ;* Title :AVR309:USB to UART protocol converter 6 ;* Date :01.02.2004 7 ;* Version :2.8 8 ;* Target MCU :ATmega8 9 ;* AUTHOR :Ing. Igor Cesko 10 ;* Slovakia 11 ;* email is hidden 12 ;* http://www.cesko.host.sk 13 ;* 14 ;* DESCRIPTION: 15 ;* USB protocol implementation into MCU with noUSB interface: 16 ;* Device: 17 ;* Universal USB interface (3x8-bit I/O port + RS232 serial line + EEPROM) 18 ;* + added RS232 FIFO buffer 19 ;* 20 ;* The timing is adapted for 12 MHz crystal 21 ;* 22 ;* 23 ;* to add your own functions - see section: TEMPLATE OF YOUR FUNCTION 24 ;* 25 ;* to customize device to your company you must change VendorUSB ID (VID) 26 ;* to VID assigned to your company (for more information see www.usb.org) 27 ;* 28 ;*************************************************************************** 29 .include "m8def.inc" 30 ;comment for AT90S2313 31 .equ UCR =UCSRB 32 .equ UBRR =UBRRL 33 .equ EEAR =EEARL 34 .equ USR =UCSRA 35 .equ E2END =127 36 .equ RAMEND128 =96+127 38 .equ inputport =PINB 39 .equ outputport =PORTB 40 .equ USBdirection =DDRB 41 .equ DATAplus =1 ;signal D+ on PB1 42 .equ DATAminus =0 ;signal D- on PB0 - give on this pin pull-up 1.5kOhm 43 .equ USBpinmask =0b11111100 ;mask low 2 bit (D+,D-) on PB 44 .equ USBpinmaskDplus =~(1<>8 ;to bitcount CRC polynomial - high byte 972 eor temp1,bitcount ;and make XOR from remains and CRC polynomial - high byte 973 ldi bitcount,CRC16poly ;to bitcount CRC polynomial - low byte 974 eor temp0,bitcount ;and make XOR of remainder and CRC polynomial - low byte 975 CRC16NoXOR: 976 dec temp3 ;were already all bits in byte 977 brne CRC16LoopByte ;unless, then go to next bit 978 cp USBBufptrY,ByteCount ;was already end-of-message 979 brne CRC16Loop ;unless then repeat 980 CRC16End: 981 ret ;otherwise finish (in temp0 and temp1 is result) 982 ;- 983 LoadDescriptorFromROM: 984 lpm ;load from ROM position pointer to R0 985 st Y+,R0 ;R0 save to buffer and increment buffer 986 adiw ZH:ZL,1 ;increment index to ROM Page: 17, 987 dec ByteCount ;till are not all bytes 988 brne LoadDescriptorFromROM ;then load next 989 rjmp EndFromRAMROM ;otherwise finish 990 ;- 991 LoadDescriptorFromROMZeroInsert: 992 lpm ;load from ROM position pointer to R0 993 st Y+,R0 ;R0 save to buffer and increment buffer 995 bst RAMread,3 ;if bit 3 is one - don't insert zero 996 brtc InsertingZero ;otherwise zero will be inserted 997 adiw ZH:ZL,1 ;increment index to ROM 998 lpm ;load from ROM position pointer to R0 999 st Y+,R0 ;R0 save to buffer and increment buffer 1000 clt ;and clear 1001 bld RAMread,3 ;the third bit in RAMread - for to the next zero insertion will be made 1002 rjmp InsertingZeroEnd ;and continue 1003 InsertingZero: 1004 clr R0 ;for insertion of zero 1005 st Y+,R0 ;zero save to buffer and increment buffer 1006 InsertingZeroEnd: 1007 adiw ZH:ZL,1 ;increment index to ROM 1008 subi ByteCount,2 ;till are not all bytes 1009 brne LoadDescriptorFromROMZeroInsert ;then load next 1010 rjmp EndFromRAMROM ;otherwise finish 1011 ;- 1012 LoadDescriptorFromSRAM: 1013 ld R0,Z ;load from position RAM pointer to R0 1014 st Y+,R0 ;R0 save to buffer and increment buffer 1015 adiw ZH:ZL,1 ;increment index to RAM 1016 dec ByteCount ;till are not all bytes 1017 brne LoadDescriptorFromSRAM ;then load next 1018 rjmp EndFromRAMROM ;otherwise finish 1019 ;- 1020 LoadDescriptorFromEEPROM: 1021 out EEARL,ZL ;set the address EEPROM Lo 1022 out EEARH,ZH ;set the address EEPROM Hi 1023 sbi EECR,EERE ;read EEPROM to register EEDR 1024 in R0,EEDR ;load from EEDR to R0 1025 st Y+,R0 ;R0 save to buffer and increment buffer 1026 adiw ZH:ZL,1 ;increment index to EEPROM 1027 dec ByteCount ;till are not all bytes 1028 brne LoadDescriptorFromEEPROM;then load next 1029 rjmp EndFromRAMROM ;otherwise finish 1030 ;- 1031 LoadXXXDescriptor: 1032 ldi temp0,SOPbyte ;SOP byte 1033 sts OutputBufferBegin,temp0 ;to begin of tramsmiting buffer store SOP 1034 ldi ByteCount,8 ;8 byte store 1035 ldi USBBufptrY,OutputBufferBegin+2 ;to transmitting buffer 1037 and RAMread,RAMread ;if will be reading from RAM or ROM or EEPROM 1038 brne FromRAMorEEPROM ;0=ROM,1=RAM,2=EEPROM,4=ROM with zero insertion (string) 1039 FromROM: 1040 rjmp LoadDescriptorFromROM ;load descriptor from ROM 1041 FromRAMorEEPROM: 1042 sbrc RAMread,2 ;if RAMREAD=4 1043 rjmp LoadDescriptorFromROMZeroInsert ;read from ROM with zero insertion 1044 sbrc RAMread,0 ;if RAMREAD=1 Page: 18, 1045 rjmp LoadDescriptorFromSRAM ;load data from SRAM 1046 rjmp LoadDescriptorFromEEPROM ;otherwise read from EEPROM 1047 EndFromRAMROM: 1048 sbrc RAMread,7 ;if is most significant bit in variable RAMread=1 1049 clr RAMread ;clear RAMread 1050 rcall ToggleDATAPID ;change DATAPID 1051 ldi USBBufptrY,OutputBufferBegin+1 ;to transmitting buffer - position of DATA PID 1052 ret 1053 ;- 1054 PrepareUSBOutAnswer: ;prepare answer to buffer 1055 rcall PrepareUSBAnswer ;prepare answer to buffer 1056 MakeOutBitStuff: 1057 inc BitStuffInOut ;transmitting buffer - insertion of bitstuff bits 1058 ldi USBBufptrY,OutputBufferBegin ;to transmitting buffer 1059 rcall BitStuff 1060 mov OutputBufferLength,ByteCount ;length of answer store for transmiting 1061 clr BitStuffInOut ;receiving buffer - deletion of bitstuff bits 1062 ret 1063 ;- 1064 PrepareUSBAnswer: ;prepare answer to buffer 1065 clr RAMread ;zero to RAMread variable - reading from ROM 1066 lds temp0,InputBufferBegin+2 ;bmRequestType to temp0 1067 lds temp1,InputBufferBegin+3 ;bRequest to temp1 1068 cbr temp0,0b10011111 ;if is 5 and 6 bit zero 1069 brne VendorRequest ;then this isn't Vendor Request 1070 rjmp StandardRequest ;but this is standard Request 1071 ;- 1072 VendorRequest: 1073 clr ZH ;for reading from RAM or EEPROM 1075 cpi temp1,1 ; 1076 brne NoDoSetInfraBufferEmpty ; 1077 rjmp DoSetInfraBufferEmpty ;restart infra receiving (if it was stopped by reading from RAM) 1078 NoDoSetInfraBufferEmpty: 1079 cpi temp1,2 ; 1080 brne NoDoGetInfraCode 1081 rjmp DoGetInfraCode ;transmit received infra code (if it is in buffer) 1082 NoDoGetInfraCode: 1083 cpi temp1,3 ; 1084 brne NoDoSetDataPortDirection 1085 rjmp DoSetDataPortDirection ;set flow direction of datal bits 1086 NoDoSetDataPortDirection: 1087 cpi temp1,4 ; 1088 brne NoDoGetDataPortDirection 1089 rjmp DoGetDataPortDirection ;detect of flow direction of data bits 1090 NoDoGetDataPortDirection: 1091 cpi temp1,5 ; 1092 brne NoDoSetOutDataPort 1093 rjmp DoSetOutDataPort ;set data bits (if they are inputs, then pull-ups) 1094 NoDoSetOutDataPort: 1095 cpi temp1,6 ; 1096 brne NoDoGetOutDataPort 1097 rjmp DoGetOutDataPort ;detect settings of data out bits (if they are input, then pull-ups) 1098 NoDoGetOutDataPort: 1099 cpi temp1,7 ; 1100 brne NoDoGetInDataPort 1101 rjmp DoGetInDataPort ;return value of input data port 1102 NoDoGetInDataPort: Page: 19, 1103 cpi temp1,8 ; 1104 brne NoDoEEPROMRead 1105 rjmp DoEEPROMRead ;return contents of EEPROM from given address 1106 NoDoEEPROMRead: 1107 cpi temp1,9 ; 1108 brne NoDoEEPROMWrite 1109 rjmp DoEEPROMWrite ;write to EEPROM to given address given data 1110 NoDoEEPROMWrite: 1111 cpi temp1,10 ; 1112 brne NoDoRS232Send 1113 rjmp DoRS232Send ;transmit byte to serial line 1114 NoDoRS232Send: 1115 cpi temp1,11 ; 1116 brne NoDoRS232Read 1117 rjmp DoRS232Read ;returns received byte from serial line 1118 NoDoRS232Read: 1119 cpi temp1,12 ; 1120 brne NoDoSetRS232Baud 1121 rjmp DoSetRS232Baud ;set line speed of of serial line 1122 NoDoSetRS232Baud: 1123 cpi temp1,13 ; 1124 brne NoDoGetRS232Baud 1125 rjmp DoGetRS232Baud ;return line speed of serial line 1126 NoDoGetRS232Baud: 1127 cpi temp1,14 ; 1128 brne NoDoGetRS232Buffer 1129 rjmp DoGetRS232Buffer ;return line speed of serial line 1130 NoDoGetRS232Buffer: 1131 cpi temp1,15 ; 1132 brne NoDoSetRS232DataBits 1133 rjmp DoSetRS232DataBits ;set line speed of serial line 1134 NoDoSetRS232DataBits: 1135 cpi temp1,16 ; 1136 brne NoDoGetRS232DataBits 1137 rjmp DoGetRS232DataBits ;return line speed of serial line 1138 NoDoGetRS232DataBits: 1139 cpi temp1,17 ; 1140 brne NoDoSetRS232Parity 1141 rjmp DoSetRS232Parity ;set line speed of serial line 1142 NoDoSetRS232Parity: 1143 cpi temp1,18 ; 1144 brne NoDoGetRS232Parity 1145 rjmp DoGetRS232Parity ;return line speed of serial line 1146 NoDoGetRS232Parity: 1147 cpi temp1,19 ; 1148 brne NoDoSetRS232StopBits 1149 rjmp DoSetRS232StopBits ;set line speed of serial line 1150 NoDoSetRS232StopBits: 1151 cpi temp1,20 ; 1152 brne NoDoGetRS232StopBits 1153 rjmp DoGetRS232StopBits ;return line speed of serial line 1154 NoDoGetRS232StopBits: 1156 cpi temp1,USER_FNC_NUMBER+0 ; 1157 brne NoDoUserFunction0 1158 rjmp DoUserFunction0 ;execute of user function0 1159 NoDoUserFunction0: 1160 cpi temp1,USER_FNC_NUMBER+1 ; Page: 20, 1161 brne NoDoUserFunction1 1162 rjmp DoUserFunction1 ;execute of user function1 1163 NoDoUserFunction1: 1164 cpi temp1,USER_FNC_NUMBER+2 ; 1165 brne NoDoUserFunction2 1166 rjmp DoUserFunction2 ;execute of user function1 1167 NoDoUserFunction2: 1169 rjmp ZeroDATA1Answer ;if that it was something unknown, then prepare zero answer 1172 ;- USER FUNCTIONS - 1174 ;-TEMPLATE OF YOUR FUNCTION- 1175 ;- BEGIN: This is template how to write own function - 1177 ;free of use are registers: 1178 ;temp0,temp1,temp2,temp3,ACC,ZH,ZL 1179 ;registers are destroyed after execution (use push/pop to save content) 1181 ;at the end of routine you must correctly set registers: 1182 ;RAMread - 0=reading from ROM, 1=reading from RAM, 2=reading from EEPROM 1183 ;temp0 - number of transmitted data bytes 1184 ;ZH,ZL - pointer to buffer of transmitted data (pointer to ROM/RAM/EEPROM) 1186 ;to transmit data (preparing data to buffer) : 1187 ;to transmit data you must jump to "ComposeEndXXXDescriptor" 1188 ;to transmit one zero byte you can jump to "OneZeroAnswer" (commonly used as confirmation of correct processing) 1189 ;to transmit two zero byte you can jump to "TwoZeroAnswer" (commonly used as confirmation of error in processing) 1190 ;for small size (up to 8 bytes) ansver use buffer AnswerArray (see function DoGetOutDataPort:) 1192 DoUserFunctionX: 1193 DoUserFunction0: ;send byte(s) of RAM starting at position given by first parameter in function 1194 lds temp0,InputBufferBegin+4 ;first parameter Lo into temp0 1195 lds temp1,InputBufferBegin+5 ;first parameter Hi into temp1 1196 ;lds temp2,InputBufferBegin+6 ;second parameter Lo into temp2 1197 ;lds temp3,InputBufferBegin+7 ;second parameter Hi into temp3 1198 ;lds ACC,InputBufferBegin+8 ;number of requested bytes from USB host (computer) into ACC 1200 ;Here add your own code: 1201 ;- 1202 nop ;example of code - nothing to do 1203 nop 1204 nop 1205 nop 1206 nop 1207 ;- 1209 mov ZL,temp0 ;will be sending value of RAM - from address stored in temp0 (first parameter Lo of function) 1210 mov ZH,temp1 ;will be sending value of RAM - from address stored in temp1 (first parameter Hi of function) 1211 inc RAMread ;RAMread=1 - reading from RAM 1212 ldi temp0,255 ;send max number of bytes - 255 bytes are maximum 1213 rjmp ComposeEndXXXDescriptor ;a prepare data 1214 DoUserFunction1: 1215 rjmp OneZeroAnswer ;only confirm receiving by one zero byte answer 1216 DoUserFunction2: 1217 rjmp TwoZeroAnswer ;only confirm receiving by two zero bytes answer 1218 ;- END: This is template how to write own function - Page: 21, 1221 ;- USER FUNCTIONS - 1222 ;- 1223 DoSetInfraBufferEmpty: 1224 rjmp OneZeroAnswer ;acknowledge reception with single zero 1225 ;- 1226 DoGetInfraCode: 1227 rjmp OneZeroAnswer ;acknowledge reception with single zero 1228 ;- 1229 DoSetDataPortDirection: 1230 lds temp1,InputBufferBegin+7 ;fourth parameter - bit mask - which port(s) to change 1232 lds temp0,InputBufferBegin+4 ;first parameter - direction of data bits DDRB 1233 andi temp0,0b00111100 ;mask unused pins 1234 sbrc temp1,0 ;if bit0 is zero - don't change port state 1235 out DDRB,temp0 ;and update direction of data port 1237 lds temp0,InputBufferBegin+5 ;second parameter - direction of data bits DDRC 1238 sbrc temp1,1 ;if bit1 is zero - don't change port state 1239 out DDRC,temp0 ;and update direction of data port 1241 lds temp0,InputBufferBegin+6 ;third parameter - direction of data bits DDRD 1242 andi temp0,0b11111000 ;mask unused pins 1243 ori temp0,0b00000010 ;mask unused pins 1244 sbrc temp1,2 ;if bit2 is zero - don't change port state 1245 out DDRD,temp0 ;and update direction of data port 1247 rjmp OneZeroAnswer ;acknowledge reception with single zero 1248 ;- 1249 DoGetDataPortDirection: 1250 in temp0,DDRB ;read direction of DDRB 1251 sts AnswerArray,temp0 ;to array AnswerArray 1252 in temp0,DDRC ;read direction of DDRC 1253 sts AnswerArray+1,temp0 ;to array AnswerArray 1254 in temp0,DDRD ;read direction of DDRD 1255 sts AnswerArray+2,temp0 ;to array AnswerArray 1256 ldi ZL,AnswerArray ;sending is value from AnswerArray 1257 ldi temp0,0x81 ;RAMREAD=1 - reading from RAM 1258 mov RAMread,temp0 ;(highest bit set to 1 - to zero RAMread immediatelly) 1259 ldi temp0,3 ;sending are three bytes 1260 rjmp ComposeEndXXXDescriptor ;and prepare data 1261 ;- 1262 DoSetOutDataPort: 1263 lds temp1,InputBufferBegin+7 ;fourth parameter - bit mask - which port(s) to change 1265 lds temp0,InputBufferBegin+4 ;first parameter - value of data bits PORTB 1266 andi temp0,0b00111100 ;mask unused pins 1267 sbrc temp1,0 ;if bit0 is zero - don't change port state 1268 out PORTB,temp0 ;and update data port 1270 lds temp0,InputBufferBegin+5 ;second parameter - value of data bits PORTC 1271 sbrc temp1,1 ;if bit1 is zero - don't change port state 1272 out PORTC,temp0 ;and update data port 1274 lds temp0,InputBufferBegin+6 ;third parameter - value of data bits PORTD 1275 andi temp0,0b11111000 ;mask unused pins 1276 ori temp0,0b00000011 ;mask unused pins Page: 22, 1277 sbrc temp1,2 ;if bit2 is zero - don't change port state 1278 out PORTD,temp0 ;and update data port 1280 rjmp OneZeroAnswer ;acknowledge reception with single zero 1281 ;- 1282 DoGetOutDataPort: 1283 in temp0,PORTB ;read PORTB 1284 sts AnswerArray,temp0 ;to array AnswerArray 1285 in temp0,PORTC ;read PORTC 1286 sts AnswerArray+1,temp0 ;to array AnswerArray 1287 in temp0,PORTD ;read PORTD 1288 sts AnswerArray+2,temp0 ;to array AnswerArray 1289 ldi ZL,AnswerArray ;sending is value from AnswerArray 1290 ldi temp0,0x81 ;RAMREAD=1 - reading from RAM 1291 mov RAMread,temp0 ;(highest bit set to 1 - to zero RAMread immediatelly) 1292 ldi temp0,3 ;sending are three bytes 1293 rjmp ComposeEndXXXDescriptor ;and prepare data 1294 ;- 1295 DoGetInDataPort: 1296 in temp0,PINB ;read PINB 1297 sts AnswerArray,temp0 ;to array AnswerArray 1298 in temp0,PINC ;read PINC 1299 sts AnswerArray+1,temp0 ;to array AnswerArray 1300 in temp0,PIND ;read PIND 1301 sts AnswerArray+2,temp0 ;to array AnswerArray 1302 ldi ZL,AnswerArray ;sending is value from AnswerArray 1303 ldi temp0,0x81 ;RAMREAD=1 - reading from RAM 1304 mov RAMread,temp0 ;(highest bit set to 1 - to zero RAMread immediatelly) 1305 ldi temp0,3 ;sending are three bytes 1306 rjmp ComposeEndXXXDescriptor ;and prepare data 1307 ;- 1308 DoGetIn: 1309 ldi ZL,0 ;sending value in R0 1310 ldi temp0,0x81 ;RAMread=1 - reading from RAM 1311 mov RAMread,temp0 ;(highest bit set to 1 - to zero RAMread immediatelly) 1312 ldi temp0,1 ;send only single byte 1313 rjmp ComposeEndXXXDescriptor ;and prepare data 1314 ;- 1315 DoEEPROMRead: 1316 lds ZL,InputBufferBegin+4 ;first parameter - offset in EEPROM 1317 lds ZH,InputBufferBegin+5 1318 ldi temp0,2 1319 mov RAMread,temp0 ;RAMREAD=2 - reading from EEPROM 1320 ldi temp0,E2END+1 ;number my byte answers to temp0 - entire length of EEPROM 1321 rjmp ComposeEndXXXDescriptor ;otherwise prepare data 1322 ;- 1323 DoEEPROMWrite: 1324 lds ZL,InputBufferBegin+4 ;first parameter - offset in EEPROM (address) 1325 lds ZH,InputBufferBegin+5 1326 lds R0,InputBufferBegin+6 ;second parameter - data to store to EEPROM (data) 1327 out EEAR,ZL ;set the address of EEPROM 1328 out EEARH,ZH 1329 out EEDR,R0 ;set the data to EEPROM 1330 cli ;disable interrupt 1331 sbi EECR,EEMWE ;set the master write enable 1332 sei ;enable interrupt (next instruction is performed) 1333 sbi EECR,EEWE ;write 1334 WaitForEEPROMReady: Page: 23, 1335 sbic EECR,EEWE ;wait to the end of write 1336 rjmp WaitForEEPROMReady ;in loop (max cca 4ms) (because of possible next reading/writing) 1337 rjmp OneZeroAnswer ;acknowledge reception with single zero 1338 ;- 1339 DoRS232Send: 1340 lds temp0,InputBufferBegin+4 ;first parameter - value transmitted to RS232 1341 out UDR,temp0 ;transmit data to UART 1342 WaitForRS232Send: 1343 sbis UCR,TXEN ;if disabled UART transmitter 1344 rjmp OneZeroAnswer ;then finish - protection because loop lock in AT90S2323/2343 1345 sbis USR,TXC ;wait for transmition finish 1346 rjmp WaitForRS232Send 1347 rjmp OneZeroAnswer ;acknowledge reception with single zero 1348 ;- 1349 DoRS232Read: 1350 rjmp TwoZeroAnswer ;only acknowledge reception with two zero 1351 ;- 1352 DoSetRS232Baud: 1353 lds temp0,InputBufferBegin+4 ;first parameter - value of baudrate of RS232 1354 lds temp1,InputBufferBegin+6 ;second parameter - baudrate of RS232 - high byte 1355 cbr temp1,1<0 1390 brne AsRequiredGetRS232Buffer ;transmit as many as requested 1391 cp ACC,temp0 ;if no requested more that I can send 1392 brcc NoShortGetRS232Buffer ;transmit as many as requested Page: 24, 1393 AsRequiredGetRS232Buffer: 1394 mov temp0,ACC 1395 ldi temp1,0 1396 NoShortGetRS232Buffer: 1397 subi temp0,2 ;substract word length 1398 sbci temp1,0 1399 lds temp2,RS232ReadPosPtr ;obtain index of reading of buffer of RS232 code 1400 lds temp3,RS232ReadPosPtr+1 1401 add temp2,temp0 ;obtain where is end 1402 adc temp3,temp1 1403 cpi temp3,HIGH(RS232BufferEnd+1) ;if it would overflow 1404 brlo ReadNoOverflow ; 1405 brne ReadOverflow ;if yes - skip to overflow 1407 cpi temp2,LOW(RS232BufferEnd+1) ;otherwise compare LSB 1408 brlo ReadNoOverflow ;and do the same 1409 ReadOverflow: 1410 subi temp2,LOW(RS232BufferEnd+1) ;caculate how many not transfered 1411 sbci temp3,HIGH(RS232BufferEnd+1) ;caculate how many not transfered 1412 sub temp0,temp2 ;and with this short length of reading 1413 sbc temp1,temp3 ;and with this short length of reading 1414 ldi temp2,LOW(RS232FIFOBegin) ;and start from zero 1415 ldi temp3,HIGH(RS232FIFOBegin) ;and start from zero 1416 ReadNoOverflow: 1417 lds ZL,RS232ReadPosPtr ;obtain index of reading of buffer of RS232 code 1418 lds ZH,RS232ReadPosPtr+1 ;obtain index of reading of buffer of RS232 code 1420 sts RS232ReadPosPtr,temp2 ;write new index of reading of buffer of RS232 code 1421 sts RS232ReadPosPtr+1,temp3 ;write new index of reading of buffer of RS232 code 1422 sbiw ZL,2 ;space for length data - transmitted as first word 1424 cbi UCR,RXCIE ;disable interrupt from UART receiving 1425 inc RAMread ;RAMread=1 reading from RAM 1426 lds temp2,RS232LengthPosPtr 1427 lds temp3,RS232LengthPosPtr+1 ;obtain buffer length of RS232 code 1428 sub temp2,temp0 ;decrement buffer length 1429 sbc temp3,temp1 1430 sts RS232LengthPosPtr,temp2 ;write new buffer length of RS232 code 1431 sts RS232LengthPosPtr+1,temp3 1432 sbi UCR,RXCIE ;enable interrupt from UART receiving 1434 st Z+,temp2 ;and save real length to packet 1435 st Z,temp3 ;and save real length to packet 1436 sbiw ZL,1 ;and set to begin 1437 inc temp0 ;and about this word increment number of transmited bytes (buffer length) 1438 inc temp0 1439 rjmp ComposeEndXXXDescriptor ;and prepare data 1440 ;- 1441 DoSetRS232DataBits: 1442 lds temp0,InputBufferBegin+4 ;first parameter - data bits 0=5db, 1=6db, 2=7db, 3=8db 1443 cpi temp0,DataBits8 ;if to set 8-bits communication 1444 breq Databits8or9Set ;then don't change 8/9 bit communication 1445 in temp1,UCSRB ;otherwise load UCSRB 1446 cbr temp1,(1<
15

Similar documents

File: X:\USERS\IGOR\DOC\WORD\Atmel\USB to RS232 Application Note\Firmware\USBtoRS232_AT90S2313\AVR Studio 4 project\USB90S2313.asm 26.1.2004
1 ;*************************************************************************** 2 ;* USBSTACKFORTHEAVRFAMILY3;* 4 ;* File Name :"USB90S2313.asm" 5 ;* Title :AVR309:USB to UART protocol converter (simple - small FIFO) 6 ;* Date :26.01.2004 7 ;* Version :2.2 8 ;* Target MCU :AT90S2313-10 9 ;* AUTHOR :I
AVR309: Software Universal Serial Bus (USB)
AVR309: Software Universal Serial Bus (USB) Features • USB (Universal Serial Bus) protocol implemented in firmware • Supports Low Speed USB (1.5Mbit/s) in accordance with USB2.0 • Implementation runs on very small AVR devices, from 2kBytes and up • Few external components required - One resistor for
Application Note
8-bit Microcontrollers Application Note AVR270: USB Mouse Demonstration Features • Runs with AT90USB Microcontrollers at 8MHz • USB Low Power Bus Powered Device (less then 100mA) • Supported by any PC running Windows® (98SE or later), Linux® or Mac OS®. • 3Kbytes of Code Required • X, Y Movement, Le
8-bit Microcontroller Application Note
8-bit Microcontroller Application Note Rev. 2547A–AVR–11/03 AVR244: AVR UART as ANSI Terminal Interface Features • Make use of standard terminal software as user interface to your application. • Enables use of a PC keyboard as input and ascii graphic to display status and control information. • Driv
MPASM USER'S GUIDE with MPLINK and MPLIB MPASM USER'S GUIDE with MPLINK and MPLIB
Adjust Spine to fit MPASM USER'S GUIDE with MPLINK and MPLIB Microchip Technology Inc. 2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 602.786.7200 Fax: 602.899.9210 © 1999 Microchip Technology Inc., Printed in the U.S.A. 3/99 DS33014 MPASM USER'S GUIDE with MPLINK and MPLIB Information only.
Microcontroller Core Features: RA5/SS/AN4 7 34 RB1RE0/RD/AN5 8 33 RB0/INT
Device Pins A/D PSP Pin Diagram PIC16C63A 28 NO NO PDIP, Windowed CERDIP PIC16C73B 28 YES NO MCLR/VPP 1 40 RB7 PIC16C65B 40 NO YES RA0/AN0 2 39 RB6 RA1/AN1 3 38 RB5 PIC16C74B 40 YES YES RA2/AN2 4 37 RB4 RA3/AN3/VREF 5 36 RB3 RA4/T0CKI 6 35 RB2 Microcontroller Core Features: RA5/SS/AN4 7 34 RB1RE0/RD
PACKAGE OPTION ADDENDUM
PCM2704 and PCM2705 Not Recommended For New Designs PCM2704, PCM2705 PCM2706, PCM2707 Burr-Brown Audio www.ti.com... SLES081F–JUNE 2003–REVISED JANUARY 2009 STEREO AUDIO DAC WITH USB INTERFACE, SINGLE-ENDED HEADPHONE OUTPUT AND S/PDIF OUTPUT 1FEATURES – External ROM Interface (PCM2704/6) 2345• On-Ch
14 + 14W STEREO AMPLIFIER WITH MUTE & ST-BY
TDA7269A 14 + 14W STEREO AMPLIFIER WITH MUTE & ST-BY WIDE SUPPLY VOLTAGE RANGE UP TO ±20V SPLIT SUPPLY HIGH OUTPUT POWER 14 + 14W @ THD =10%, RL = 8Ω, VS = +16V NO POP AT TURN-ON/OFF MUTE (POP FREE) STAND-BY FEATURE (LOW Iq) SHORT CIRCUIT PROTECTION TO GND THERMAL OVERLOAD PROTECTION Multiwatt11 OR
FOREWORD This repair manual has been prepared to provide essential in-
FOREWORD This repair manual has been prepared to provide essential in- formation on body panel repair methods (including cutting and welding operations, but excluding painting) for the TOYOTA YARIS. Applicable models: KSP90 series Applicable models: NCP90, 91 series This manual consists of body repa
MPASM and MPLINK PICmicro® QUICK REFERENCE GUIDE
MPASM and MPLINK PICmicro® QUICK REFERENCE GUIDE The Embedded Control Solutions Company® MPASM Quick Reference Guide This Quick Reference Guide gives all the instructions, directives, and command line options for the Microchip MPASM Assembler. MPASM Directive Language Summary Directive Description S
M INTRODUCTION
M Author: Mark Palmer Microchip Technology Inc. INTRODUCTION The PICmicro™ families of RISC microcontrollers are designed to provide advanced performance and a cost-effective solution for a variety of applications. To address these applications, there is the PIC16CXXX microcontroller family of produ
M ENGINE ON-VEHICLE INSPECTION ASSEMBLY
1NZ-FE ENGINE MECHANICAL – ENGINE EM–1 M ENGINE ON-VEHICLE INSPECTION 1. INSPECT ENGINE COOLANT (See page CO-1) 2. INSPECT ENGINE OIL (See page LU-1) 3. INSPECT BATTERY (See page CH-4) 4. INSPECT AIR CLEANER FILTER ELEMENT SUB- ASSEMBLY (a) Remove the air cleaner filter element sub-assembly. (b) Vis
FOREWORD This wiring diagram manual has been prepared to provide information on the electrical system of the 2007 YARIS. Applicable models: NCP91, 93 Series
FOREWORD This wiring diagram manual has been prepared to provide information on the electrical system of the 2007 YARIS. Applicable models: NCP91, 93 Series Refer to the following manuals for additional service specifications and repair procedures for these models: Manual Name Pub. No. 2007 YARIS Re
X AUTOMATIC TRANSAXLE SYSTEM PRECAUTION
U340E AUTOMATIC TRANSAXLE – AUTOMATIC TRANSAXLE SYSTEM AX–1 X AUTOMATIC TRANSAXLE SYSTEM PRECAUTION NOTICE: • Perform the RESET MEMORY (AT initialization) when replacing the automatic transaxle assembly, engine assembly or ECM (See page AX-14). • Perform the REGISTRATION (VIN registration) when repl
ON Semiconductor 2N5550 Amplifier Transistors NPN Silicon 2N5551*
ON Semiconductor 2N5550 Amplifier Transistors NPN Silicon 2N5551* *ON Semiconductor Preferred Device MAXIMUM RATINGS Rating Symbol 2N5550 2N5551 Unit Collector–Emitter Voltage VCEO 140 160 Vdc Collector–Base Voltage VCBO 160 180 Vdc Emitter–Base Voltage VEBO 6.0 Vdc Collector Current — Continuous IC
GENERAL DESCRIPTION QUICK REFERENCE DATA PINNING - TO92 variant PIN CONFIGURATION SYMBOL
GENERAL DESCRIPTION QUICK REFERENCE DATA Glass passivated sensitive gate SYMBOL PARAMETER MAX. UNIT thyristor in a plastic envelope, intended for use in general purpose VDRM, Repetitive peak off-state voltages 200 V switching and phase control VRRM applications. This device is intended IT(AV) Averag
N-Channel JFETs
N-Channel JFETs 2N4117A PN4117A SST4117 2N4118A PN4118A SST4118 2N4119A PN4119A SST4119 Part Number VGS(off) (V) V(BR)GSS Min (V) gfs Min (S) IDSS Min (A) 4117 –0.6 to –1.8 –40 70 30 4118 –1 to –3 –40 80 80 4119 –2 to –6 –40 100 200 Ultra-Low Leakage: 0.2 pA Insignificant Signal Loss/Error Voltage
Order this document SEMICONDUCTOR TECHNICAL DATA by 2N3903/D NPN Silicon
Order this document SEMICONDUCTOR TECHNICAL DATA by 2N3903/D NPN Silicon *Motorola Preferred Device COLLECTOR BASE EMITTER 1 MAXIMUM RATINGS Rating Symbol Value Unit CASE 29–04, STYLE 1 TO–92 (TO–226AA) Collector–Emitter Voltage VCEO 40 Vdc Collector–Base Voltage VCBO 60 Vdc Emitter–Base Voltage VEB
DISCRETE SEMICONDUCTORS DATA SHEET 2N2222; 2N2222A NPN switching transistors Product specification 1997 May 29 Supersedes data of September 1994 File under Discrete Semiconductors, SC04
DISCRETE SEMICONDUCTORS DATA SHEET M3D125 2N2222; 2N2222A NPN switching transistors Product specification 1997 May 29 Supersedes data of September 1994 File under Discrete Semiconductors, SC04 FEATURES PINNING • High current (max. 800 mA) PIN DESCRIPTION • Low voltage (max. 40 V). 1 emitter 2 base A
Small-signal Transistors Selection guide
Philips Semiconductors Small-signal Transistors Selection guide V TYPE CEO IC Ptot fhhTPNP PACKAGE max. max. max. FE FE min. PAGE NUMBER min. max. COMPL. (V) (mA) (mW) (MHz) BC846 SOT23 65 100 250 110 450 100 BC856 305 BC846A SOT23 65 100 250 110 220 100 BC856A 305 BC846AT SC-75 65 100 150 110 220 1
Small-signal Transistors Selection guide
Philips Semiconductors Small-signal Transistors Selection guide SURFACE-MOUNT DEVICES NPN GENERAL PURPOSE LOW-POWER TRANSISTORSVIPfTYPE CEO C tothhTPNP PACKAGE max. max. max. FE FE min. PAGE NUMBER min. max. COMPL. (V) (mA) (mW) (MHz) 2PC4081 SC-70 40 100 200 120 560 100 2PA1576 210 2PC4081Q SC-70 4
Small-signal Transistors Selection guide
Philips Semiconductors Small-signal Transistors Selection guide LEADED DEVICES (continued) NPN HIGH-VOLTAGE POWER TRANSISTORSVIPfTYPE CEO C tothhTPACKAGE max. max. max. FE FE PNP min. PAGE NUMBER min. max. COMPL. (V) (mA) (mW) (MHz) BF419 TO-126 250 300 6000 45 typ. >45 90 – 532 BF457 TO-126 160 100
DISCRETE SEMICONDUCTORS DATA SHEET 1PS302 High-speed double diode Product specification 1996 Apr 03 File under Discrete Semiconductors, SC01
DISCRETE SEMICONDUCTORS DATA SHEET handbook, halfpage M3D114 1PS302 High-speed double diode Product specification 1996 Apr 03 File under Discrete Semiconductors, SC01 FEATURES DESCRIPTION PINNING • Very small plastic SMD package The 1PS302 consists of two PIN DESCRIPTION • High switching speed: max.
Small-signal Transistors Selection guide
Philips Semiconductors Small-signal Transistors Selection guide LEADED DEVICES NPN GENERAL PURPOSE LOW-POWER TRANSISTORSVIPfTYPE CEO C tothhTPACKAGE max. max. max. FE FE PNP min. PAGE NUMBER min. max. COMPL. (V) (mA) (mW) (MHz) 2N2484 TO-18 60 50 360 250 800 60 – 131 2N4124 TO-92 25 200 500 120 360
DISCRETE SEMICONDUCTORS DATA SHEET 1PS301 High-speed double diode Product specification 1996 Apr 03 File under Discrete Semiconductors, SC01
DISCRETE SEMICONDUCTORS DATA SHEET handbook, halfpage M3D114 1PS301 High-speed double diode Product specification 1996 Apr 03 File under Discrete Semiconductors, SC01 FEATURES DESCRIPTION PINNING • Very small plastic SMD package The 1PS301 consists of two PIN DESCRIPTION • High switching speed: max.
DISCRETE SEMICONDUCTORS DATA SHEET 1PS300 High-speed double diode Product specification 1996 Apr 03 File under Discrete Semiconductors, SC01
DISCRETE SEMICONDUCTORS DATA SHEET handbook, halfpage M3D114 1PS300 High-speed double diode Product specification 1996 Apr 03 File under Discrete Semiconductors, SC01 FEATURES DESCRIPTION PINNING • Very small plastic SMD package The 1PS300 consists of two PIN DESCRIPTION • High switching speed: max.
DISCRETE SEMICONDUCTORS DATA SHEET 1PS226 High-speed double diode Product specification 1996 Apr 03 Supersedes data of December 1993 File under Discrete Semiconductors, SC01
DISCRETE SEMICONDUCTORS DATA SHEET handbook, halfpage M3D114 1PS226 High-speed double diode Product specification 1996 Apr 03 Supersedes data of December 1993 File under Discrete Semiconductors, SC01 FEATURES DESCRIPTION PINNING • Small plastic SMD package The 1PS226 consists of two PIN DESCRIPTION
DISCRETE SEMICONDUCTORS DATA SHEET 1PS193 High-speed diode Product specification 1996 Apr 03 Supersedes data of December 1993 File under Discrete Semiconductors, SC01
DISCRETE SEMICONDUCTORS DATA SHEET handbook, halfpage M3D114 1PS193 High-speed diode Product specification 1996 Apr 03 Supersedes data of December 1993 File under Discrete Semiconductors, SC01 FEATURES DESCRIPTION PINNING • Small plastic SMD package The 1PS193 is a high-speed PIN DESCRIPTION • High
DISCRETE SEMICONDUCTORS DATA SHEET 1PS184 High-speed double diode Product specification 1996 Apr 03 Supersedes data of December 1993 File under Discrete Semiconductors, SC01
DISCRETE SEMICONDUCTORS DATA SHEET handbook, halfpage M3D114 1PS184 High-speed double diode Product specification 1996 Apr 03 Supersedes data of December 1993 File under Discrete Semiconductors, SC01 FEATURES DESCRIPTION PINNING • Small plastic SMD package The 1PS184 consists of two PIN DESCRIPTION
DISCRETE SEMICONDUCTORS DATA SHEET 1PS181 High-speed double diode Product specification 1996 Apr 03 Supersedes data of December 1993 File under Discrete Semiconductors, SC01
DISCRETE SEMICONDUCTORS DATA SHEET handbook, halfpage M3D114 1PS181 High-speed double diode Product specification 1996 Apr 03 Supersedes data of December 1993 File under Discrete Semiconductors, SC01 FEATURES DESCRIPTION PINNING • Small plastic SMD package The 1PS181 consists of two PIN DESCRIPTION

© DownloadDoc 2020

Terms and conditions | Privacy policy | Sitemap