Hi again
The stepper driver ic L298n with L297 controller ic.
When upload if maps to pic method is as follows.
1 send numeric value 1 to select case 1 load map data
2 pc waits to receive "R" (pic ready)
3 send first packet "AxxxxBxxxx" A= address B= data
4 write data to eeprom or code space depending if A value < 128
5 send "s" to PC
6 wait for next packet
7 if "A9999" received end of data transfer
Sometimes upload is fine.
There is 13 blocks of 256 words that make up the map data and when I view the pic memory I can see areas with rows of zeros and some 00001 and 00002 where a value of 55 should be. this fail area is for 4 memory rows and then comes good. When upload of map is in progress the stepper driver is set to disable and .12 amp of draw only from power supply in this state so noise at this time is unlikely.
see picture taken from meProg The row with 11111 is a partition only and npt read. Below that the values should be progressively larger than the 45 values that are correct.
Beginning to suspect the usb to serial adapter. This is difficult to see because if the data string is not AxxxxBxxxx then error occures. so the error is only in the values after B as the correct addresses are written . It is as if the charge pump runs out in the pic and then recovers. Also the defective area is mainly in a similar area. Tricky hey
Code:'-------------Main Code------------ DEFINE HSER_RCSTA 90h DEFINE HSER_TXSTA 24h DEFINE HSER_BAUD 76800 DEFINE HSER_EVEN 1 DEFINE OSC 20 INTCON2.7=0 ' Enable PORTB pull-ups 18f458 TRISB = 110000 PORTB = 000001 loadlamp1 var word loadlamp2 var word mapflag var byte data1 VAR word location VAR word computercontrol var byte computerpos VAR word connect var byte '------------------------------------------------------------------------------------------------------ mainloop: if RCSTA.1 then ' Overrun error? used to reset input ready to recieve RCSTA.4=0 ' clear it RCSTA.4=1 endif if PIR1.5 then gosub loaddata 'if a chaeacter has arived at serial in the PIR1.5 will = 1 goto mainloop: '------------------------------------------------------------------------------------------------ Loaddata: hserin [dec1 data1] 'read case number from pc 1 = load 2 = computer control 4 = connection extablished 5 = disconnect select case data1 case 1 loadlamp1 = 0 loadlamp2 = 6 HSEROUT ["R"] 'pic ready to recieve Load2: HSERIN 5000,TimeOut2,[WAIT("A"),hex4 location,WAIT("B"),hex4 data1] 'if next packet not recieved in 5 sec then go timeout 2 loadlamp1 = loadlamp1 + 1 'led flash while data transfer in progress if loadlamp1 > loadlamp2 then PORTB=PORTB << 1 if loadlamp1 > loadlamp2 then loadlamp2 = loadlamp1 + 6 IF PORTB.3 THEN PORTB = 000001 if location = 9999 then goto TimeOut2 'when A9999B0000 sent from pc data transfer finished if location > 128 then goto cs 'codespace addresses are always greater than 128 write location , data1.lowbyte write location+128 , data1.highbyte HSEROUT ["S"] 'please send next data packet GOTO Load2: cs: Writecode location ,data1 HSEROUT ["S"] 'please send next data packet GOTO Load2 TimeOut2: if location = 9999 then HSEROUT ["Recieve ok"] else HSEROUT ["F"] 'fail load set to pc endif HSERIN 20,TimeOut3,[WAIT("recieve nill")] 'this is needed to final clear PIR1.5 and stops main loop jump to loaddata TimeOut3: PORTB = 000001 RETURN case 2 HSEROUT ["R"] computercontrol=1 HSERIN 5000,TimeOut2,[WAIT("P"),dec3 computerpos] location = 9999 goto TimeOut2 case 3 HSEROUT ["R"] computercontrol=0 location = 9999 goto TimeOut2 case 4 HSEROUT ["C"] connect=1 location = 9999 goto TimeOut2 case 5 HSEROUT ["D"] connect=0 location = 9999 goto TimeOut2 end select return end





Bookmarks