NU32: Using the dsPIC33FJ12MC201 QEI to SPI board

From Mech
Revision as of 13:59, 17 February 2012 by NickMarchuk (talk | contribs) (New page: Using the dsPIC33FJ for quad decode == Overview == Why this chip == Details == The board == Library Functions == This code How to get the count The f...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Using the dsPIC33FJ for quad decode

Overview

Why this chip

Details

The board

Library Functions

This code How to get the count

The functions are:

  • void NU32_Initialize(void) - enables UART1 and UART4 at 115200 baud. UART4 starts with the interrupt at priority level 3, UART1 starts with no interrupt enabled
  • void NU32_EnableUART1Interrupt(void) - enables the UART1 interrupt
  • void NU32_WriteUART1(const char *) - call with the character array you wish to send, make the array with sprintf()
  • void NU32_ReadUART1(char *, int) - call with the array you want to read into, and the maximum size of the array. The code will wait at this function and buffer all characters received until you send a '\r' or '\n' (by pressing [enter] on your keyboard)

NU32Example.c in the .zip file above demonstrates how to use the functions.

Sample Code

To initialize the serial communication, call NU32_Initialize(), :

  NU32_Initialize();

To write a string to the computer, use NU32_WriteUART1(charArray). The special characters '\r' and '\n' are carriage return and newline. Using them together puts the cursor on the next line.

  NU32_WriteUART1("\r\nHello World!\r\n");

To write a string with the value of a variable in it, use sprintf(charArray,"%d") and NU32_WriteUART1(charArray).

More Information

NA