ismu
Full Member level 2
- Joined
- May 12, 2009
- Messages
- 145
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,298
- Location
- nil
- Activity points
- 2,340
i am trying to program/erase dsPIC30F2010 using ICSP protocol [App note S70102J ] by using normal 16F73 . see diagram and code of 16f73.
Am getting the pulses currectly , but chip erase is not working , like this ,itried chip program ,also not working . pls verify bellow code.
ICSP algoritham based on microchip App note S70102J
//////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
Am getting the pulses currectly , but chip erase is not working , like this ,itried chip program ,also not working . pls verify bellow code.
ICSP algoritham based on microchip App note S70102J
//////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 void main() { TRISB=0b00000001; TRISA=0b00000000; ADCON1=0b00000110; TRISC=0b00000000; VDD=1; for(;;) { stop(); if(!PROGRAM) ////switch is active { start_ICSP(); Bulk_Erase(); stop(); } } } /////////////////////////////////////////////////////////////////// void stop(void) { DAT=0; CLK=0; MCLR=0; __delay_ms(100); } //////////////////////////// void start_ICSP(void) { stop(); __delay_us(1); ///100ns is min MCLR=1; __delay_ms(30); ///25ms is min dspic_send_24_bits(0,0); __delay_ms(1); dspic_send_24_bits(0,0); __delay_ms(1); dspic_send_24_bits(0,0); __delay_ms(1); dspic_send_24_bits(0,0); __delay_ms(1); MCLR=0; __delay_us(1); ///4us is min MCLR=1; } ///////////////////////////// void Bulk_Erase(void) { dspic_send_24_bits(0,0); dspic_send_24_bits(0,0); dspic_send_24_bits(0,0x040100); dspic_send_24_bits(0,0x040100); dspic_send_24_bits(0,0); dspic_send_24_bits(0,0x2407FA); dspic_send_24_bits(0,0x883B0A); dspic_send_24_bits(0,0x200558); dspic_send_24_bits(0,0x883B38); dspic_send_24_bits(0,0x200AA9); dspic_send_24_bits(0,0x883B39); dspic_send_24_bits(0,0xA8E761); dspic_send_24_bits(0,0x0); dspic_send_24_bits(0,0x0); __delay_ms(2); dspic_send_24_bits(0,0x0); dspic_send_24_bits(0,0x0); dspic_send_24_bits(0,0xA9E761); dspic_send_24_bits(0,0x0); dspic_send_24_bits(0,0x0); __delay_ms(2); } /////////////////////////////// /////////////////////////////////////////////////////////////////// void dspic_send_24_bits(unsigned char SIX_CMD_or_REGOUT, unsigned long data) { unsigned char i,cmd_temp; cmd_temp=cmd; for(i=0;i<4;i++) { if(cmd&1) DAT=1; else DAT=0; cmd>>=1; __delay_us(5); CLK=1; __delay_us(5); CLK=0; } for(i=0;i<24;i++) { if(cmd_temp==0) { TRISA=0b00000000; if(data&1) DAT=1; else DAT=0; data>>=1; } else if(cmd_temp==1&&i>7) { TRISA=0b00001000; } __delay_us(5); CLK=1; __delay_us(5); CLK=0; } TRISA=0b00000000; }
Attachments
Last edited by a moderator: