Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Code composer studio code that reads text file, coverts to ascii, then convert the ascii characters to binary and output the binary digits to an

Code composer studio code that reads text file, coverts to ascii, then convert the ascii characters to binary and output the binary digits to an MSP432. My code works in other C compliers like code blocks or visual studio but im getting stuck in the first while loop in code composer. Any ideas on how to fix this?

stepping through the code shows that the file is being read, however the code doesnt go further than that

//***************************************************************************** // // MSP432 main.c template - Empty main // //****************************************************************************

#include "msp.h" #include #include

int main() {

WDTCTL = WDTPW + WDTHOLD;

P3DIR |= BIT2 + BIT3; P4DIR |= BIT0 + BIT1 + BIT2 + BIT3; // P4.0 = Write, P4.2 = Read P6DIR |= BIT1; // P6.1 = Register select

FILE *fpointer; int binaryRep[4000], rev[5]; int j = 0, k; char c; char text[4000]; int i = 0; int val; int l = 0; int m = 0; int temp; int D0, D1, D3, D2;

int h = 0; int transmitcounter = 0;

//Reading data from file fpointer = fopen("C://Users//User//Documents//input.txt", "r+");

j = 0;

//printf(" Representing ASCII in 3 digit format: "); while ((c = fgetc(fpointer)) != EOF) { //Represent each character into ASCII of 3-digit format temp = c; //sprintf(text, "%3.*d", 3, temp);

//Forming each digit to equivalent binary form for (i = 0; text[i] != '\0'; i++) { //printf(" %c", text[i]); val = text[i]; k = 0, l = 0;

//Getting binary number while (val>0 && k<4) { rev[l] = val % 2; k++; l++; val = val / 2; }

//Store in correct order for (m = l - 1; m >= 0; m--) { binaryRep[j] = rev[m]; j++; } } }

//Output the entire binary representation /*printf(" Representing ASCII of 3 digit format in binary: "); for (i = 0; i

while (h < 4000) { transmitcounter = 0; D3 = binaryRep[h]; h++; D2 = binaryRep[h]; h++; D1 = binaryRep[h]; h++; D0 = binaryRep[h]; h++;

if (D3 == 1) P3OUT |= BIT2; if (D2 == 1) P3OUT |= BIT3; if (D1 == 1) P4OUT |= BIT1; if (D0 == 1) P4OUT |= BIT3;

//printf("%d%d%d%d ", D3, D2, D1, D0);

while (transmitcounter < 100) transmitcounter++;

}

fclose(fpointer); //system("pause"); return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago