Question: #include saml21j18b.h unsigned char* ARRAY_PORT_PINCFG0 = (unsigned char*)®_PORT_PINCFG0; unsigned char* ARRAY_PORT_PMUX0 = (unsigned char*)®_PORT_PMUX0; int main(void) { int c; //REG_MCLK_AHBMASK |= 0x00000004; /* APBC bus

#include "saml21j18b.h"

unsigned char* ARRAY_PORT_PINCFG0 = (unsigned char*)®_PORT_PINCFG0; unsigned char* ARRAY_PORT_PMUX0 = (unsigned char*)®_PORT_PMUX0;

int main(void) { int c; //REG_MCLK_AHBMASK |= 0x00000004; /* APBC bus clock enabled by default */ //REG_MCLK_APBCMASK |= 0x00000002; /* SERCOM1 APBC bus clock enabled by default */ // Generic clock generator 0, enabled at reset @ 4MHz, is used for peripheral clock REG_GCLK_PCHCTRL19 = 0x00000040; /* SERCOM1 core clock not enabled by default */

ARRAY_PORT_PINCFG0[16] |= 1; /* allow pmux to set PA16 pin configuration */ ARRAY_PORT_PINCFG0[17] |= 1; /* allow pmux to set PA17 pin configuration */ ARRAY_PORT_PINCFG0[18] |= 1; /* allow pmux to set PA18 pin configuration */ ARRAY_PORT_PINCFG0[19] |= 1; /* allow pmux to set PA19 pin configuration */ ARRAY_PORT_PMUX0[8] = 0x22; /* PA16 = MOSI, PA17 = SCK */ ARRAY_PORT_PMUX0[9] = 0x22; /* PA18 = SS, PA19 = MISO */

REG_SERCOM1_SPI_CTRLA = 1; /* reset SERCOM1 */ while (REG_SERCOM1_SPI_CTRLA & 1) {} /* wait for reset to complete */ REG_SERCOM1_SPI_CTRLA = 0x0030000C; /* MISO-3, MOSI-0, SCK-1, SS-2, SPI master */ REG_SERCOM1_SPI_CTRLB = 0x00002000; /* Master SS, 8-bit */ REG_SERCOM1_SPI_BAUD = 0; /* SPI clock is 1MHz/2 = 500kHz */ REG_SERCOM1_SPI_CTRLA |= 2; /* enable SERCOM1 */ while(1) { for (c = 'A'; c <= 'Z'; c++) { while(!(REG_SERCOM1_SPI_INTFLAG & 1)) {} /* wait until Tx ready */ REG_SERCOM1_SPI_DATA = c; /* send data byte */ } } }

question:

Modify the program given, the program must make CPOL = 0, CPHA = 0 and the baud rate must be 1 Mhz.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!