So far so good
programming header spliced in so I can program the dspic with the pickit programmer. (Only need to this this on one as I can program the chips for others in this board).
Command line compiler purchased. $250 ouch. This translates the source code in 'C' to the machine code run by the chip.
Noddy program written (along the lines of 10 print "hello world", 20 goto 10
). In this case set the pins to input & output correctly, then invert the INJ4 line each time round the loop with a delay in between.
Result above.
For those interested, the source code used:
Quote:
#device dspic33FJ128GP802
#FUSES NOPROTECT,NOIESO,PR_PLL,NOOSCIO,HS,WDT,WINDIS,ALTI2C
typedef int16 word; // word is unsigned int
typedef int16 uword; // uword is unsigned int
typedef signed int16 sword; // sword is signed int
typedef char uchar; // uchar is unsigned char
typedef signed int8 schar; // schar is signed char
//ports
#word TRISA = 0x02C0
#word PORTA = 0x02C2
#word LATA = 0x02C4
#word ODCA = 0x02C6
#word TRISB = 0x02C8
#word PORTB = 0x02CA
#word LATB = 0x02CC
#word ODCB = 0x02CE
void main(void)
{
uword itmp;
// powerup / reset initialisation
PORTA = 0;
PORTB = 0;
// main loop
while (1)
{
// each loop initialisation
#asm
CLRWDT
#endasm
TRISA = 0xFFEF; // set i/o pins
ODCA = 0;
TRISB = 0x2477;
ODCB = 0x0060;
//
PORTB ^= 0x0200;
for (itmp = 0;itmp < 10000;itmp++);
};
The output code produced by the compiler (in readable form)
Quote:
.................... void main(void)
.................... {
*
00200: BSET.B 81.7
00202: SETM 32C
00204: MOV #3F80,W15
00206: MOV #3FFF,W0
00208: MOV W0,20
0020A: NOP
0020C: MOV #3F80,W15
0020E: MOV #3FFF,W0
00210: MOV W0,20
00212: NOP
.................... uword itmp;
....................
.................... // powerup / reset initialisation
.................... PORTA = 0;
00214: CLR 2C2
.................... PORTB = 0;
00216: CLR 2CA
.................... // main loop
.................... while (1)
.................... {
.................... // each loop initialisation
.................... #asm
.................... CLRWDT
00218: CLRWDT
.................... #endasm
.................... TRISA = 0xFFEF; // set i/o pins
0021A: MOV #FFEF,W4
0021C: MOV W4,2C0
.................... ODCA = 0;
0021E: CLR 2C6
.................... TRISB = 0x2477;
00220: MOV #2477,W4
00222: MOV W4,2C8
.................... ODCB = 0x0060;
00224: MOV #60,W4
00226: MOV W4,2CE
.................... //
.................... PORTB ^= 0x0200;
00228: BTG.B 2CB.1
.................... for (itmp = 0;itmp < 10000;itmp++);
0022A: CLR 802
0022C: MOV 802,W4
0022E: MOV #2710,W3
00230: CP W3,W4
00232: BRA LE,23A
00234: INC 0802
00236: GOTO 22C
.................... };
0023A: GOTO 218
.................... }
0023E: PWRSAV #0
_________________
If at first you don't suck seed, try drier grain.