Shop OBEX P1 Docs P2 Docs Learn Events
C3 and I forgot... — Parallax Forums

C3 and I forgot...

RsadeikaRsadeika Posts: 3,837
edited 2014-01-23 14:31 in Propeller 1
how to code in C. Below the program blinks the LED but I do not get the - printf("Starting blinky\n"); to show on the terminal screen. I am working in project view. When I remove the 'auto sd_mount' stuff, then I get "Starting blinky" on the terminal screen, in all memory modes. Must be something really dumb that I am doing.

Thanks

Ray
/**
 * scratch1.c
 */
#include <stdio.h>
#include <propeller.h>

/* Auto sd_mount of SD. */
extern _Driver _NullDriver;
extern _Driver _FileDriver;

_Driver *_driverlist[] = {
  &_NullDriver,
  &_FileDriver,
  NULL
};


void high(int pin)                            // high function definition
{
  int mask = 1 << pin;                        // Set up mask
  OUTA |= mask;                               // Bitwise OR w/ OUTA & DIRA
  DIRA |= mask;
}

void low(int pin)                             // low function definition
{
  int mask = 1 << pin;                        // Set up mask
  OUTA &= ~mask;                              // Pin output state to low
  DIRA |= mask;                               // Pin direction to output
}

int main(void)
{
  sleep(1);
  printf("Starting blinky\n");

  while(1)
  {
    high(23);
    sleep(1);
    low(23);
    sleep(1);
  }

  return 0;
}

Comments

  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-23 13:39
    I think it is writing your "Starting..." message to the NUL device because that's what you have listed first in your _driverlist array. Try replacing that with "_SimpleSerialDriver" and you should see some output.
  • mindrobotsmindrobots Posts: 6,506
    edited 2014-01-23 13:53
    Ray,

    I remember the C3 SD card is different. It's on a shared SPI bus.....ok, I forgot the details beyond this. Check the C3 docs and in PropGCC are their especial C3 demo programs for some functions?
  • RsadeikaRsadeika Posts: 3,837
    edited 2014-01-23 14:27
    Thanks David, I kind of figured it would be something dumb like that. I am curious, why is initiating the SD tied to a drivers list that is tied too a _simpleSerialDriver, that is tied too getting output to the terminal screen. After all, you are getting output the terminal screen if you do not have the 'auto sd_mount' stuff.

    Ray
  • David BetzDavid Betz Posts: 14,516
    edited 2014-01-23 14:31
    Rsadeika wrote: »
    Thanks David, I kind of figured it would be something dumb like that. I am curious, why is initiating the SD tied to a drivers list that is tied too a _simpleSerialDriver, that is tied too getting output to the terminal screen. After all, you are getting output the terminal screen if you do not have the 'auto sd_mount' stuff.

    Ray
    The SD driver isn't included by default to save space. It isn't the auto-mounting that is tied to _driverlist. It is any use of the SD card filesystem. You'd need to add that to the driver list even if you were planning to manually mount the SD filesystem. The alternative would be to always include the SD driver but that would waste space for applications that don't need it. Also, once you explicitly define _driverlist, you must make sure that the first drive in the list can handle console I/O since that is the driver that will be used for stdin, stdout, and stderr.
Sign In or Register to comment.