Matrix C

The primary product line of Matrix Multimedia is a user-friendly hardware system, E-blocks, that allows different systems to be assembled using plug-in modules. The processor module incorporates sockets for a range of PIC MCUs and a number of D-type connectors. Peripheral modules with push buttons, LEDs, displays, keypad, relays, communications interfaces, and so on are added as required (Figure D.2).

Figure D.2. Matrix Multimedia Modular PIC System


The application programming can be implemented using a choice of assembler or C. Matrix also offers a proprietary flowchart-based programming system, Flowcode. The program is constructed using flowchart blocks, which are automatically converted to C and hence to assembler and machine code.

The C syntax used is illustrated in Listing D.5—a simple program to read an analog input and display the result. As in many C compilers for PIC, the control registers are loaded directly, and no special functions are used for peripheral access. The programming system is described via a tutorial, which is included with the compiler, so no separate reference manual is provided.

Listing D.5. Matrix C Source Code Sample (ADC Input and Display)

#include <system.h>

void setupADC(void)

{ trisb=0×00; /* Port B display */

trisa=0xf1; /* RA0 input, RA1-3 output */

adcon0=0×00; /* Set up ADC */

adcon1=0×80; /* Set up ADC */

ansel=0×01; /* Select AN0 only */

}

void main(void)

{

setupADC(); /* Call setup function */

while (1) /* Loop always */

{adcon0=0×05; /* Start ADC */

while(adcon0&0×04); /* Wait until done */

portb=adresl; /* Display low byte */

porta=adresh*2; /* Display high bits */

}

}

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.149.94