
AN1816
18
Application Note
This source code is example code that could be used to perform initialisation.
Fr eescal e
reserves the right to make changes without further notice to any product
herein to improve reliability, function, or design.
Fr eescal e
does not assume any
liability arising out of the application or use of any product, circuit or software
described herein; neither does it convey any licensed under its patent rights nor the
right of others.
Fr eescal e
products are not designed, intended or authorised for use
as components intended for surgical implant into the body, or other applications
intended to support life, or any other application in which failure of the
Fr eescal e
product could create a situation where personal injury or death may occur. Should
Buyer purchase or use
Fr eescal e
products for any such intended or unauthorised
application, Buyer shall indemnify and hold
Fr eescal e
and its officers, employees,
subsidiaries, affiliates, and distributors harmless against all claims, costs,
damages, expenses and reasonable attorney fees arising out of, directly or indirectly,
any claim of personal injury or death associated with such unintended or unauthorised
use, even if such a claim alleges that
Fr eescal e
was negligent regarding the design
or manufacture of the part.
Fr eescal e
and the
Fr eescal e
logo are registered trademarks
of
Fr eescal e Sem conduct or , I nc
.
***********************************************************************************/
#include <stdio.h>
#include “B32DSI.h”
#define ArraySize 0x0F /* (no. of slave nodes) */
short TBytes [ArraySize]; /* Array of bytes to be transmitted */
short RBytes [ArraySize]; /* Array of received bytes */
short ChkBytes [ArraySize]; /* Array of check bytes to check
received data is correct */
short ErrorCode [ArraySize]; /* Array of Error codes */
/* This function sets up the PWM of the HC912B32 */
void InitPWM(void)
{
PWCLK = 0x00; /* Don’t divide A clock */
PWPOL = 0x00; /* Use A clock and polarity is low until duty
count is reached */
PWPER0 = 0x1b; /* Period of 3.5
PWDTY0 = 0x0d; /* Duty cycle is 50% */
DDRP = 0x01; /* Set up PTP0 as output */
PWCTL = 0x00; /* Left aligned mode as CENTR=0 */
PWEN = 0x01; /* Enable the PWM */
}
μ
s (frequency of 285.71 kHz) */
/* This function sets up the SPI of the HC912B32 */
void InitSPI(void)
{
PURDS = 0x00; /* Leave as normal conditions */
SP0BR = 0x00; /* SPI clock frequency is 4 MHz */
SP0CR1 = 0x00; /* CPOL = CPHA = 0 */
DDRS = 0xe0; /* Set up PTS[7:5] as outputs (SS, SCLK and
MOSI) */
F
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
.