Shop OBEX P1 Docs P2 Docs Learn Events
SimpleIDE Terminal Doesn't Show when `printf`ed — Parallax Forums

SimpleIDE Terminal Doesn't Show when `printf`ed

sshaginyansshaginyan Posts: 9
edited 2013-06-06 09:19 in Learn with BlocklyProp
I have a p8X32A breakout board https://www.sparkfun.com/products/11525 and a FTDI Basic Breakout - 3.3V https://www.sparkfun.com/products/9873. Everything is working, however I can't get the printf function is display information within the SimpleIDE Terminal. I've read the documentation https://sites.google.com/site/propellergcc/documentation/libraries#TOC-COG-Device-Library and tried these the examples there. I've also tried running the hello.c example program with no success. Is there anything special I need to do to stdout stdin strerror streams? Maybe redirect them?

I know the standard baud rate is 115200 and for board type I have RCFAST.

I've tried setting a baud rate with
[COLOR=#006000][FONT=monospace]freopen("SSER:9600,31,30", "w", stdout); [/FONT][/COLOR]

and
[COLOR=#006000][FONT=monospace]waitcnt(CLKFREQ+CNT);[/FONT][/COLOR]
/*
  Blank Simple Project.c
  Click Help and select Tutorials to see lots of code examples. 
*/


#include "simpletools.h"                      // Include simple tools


int main()                                    // Main function
{
  // Add startup code here.


  while(1)                                    // Repeat indefinitely
  {
    printf("Hello world");
    pause(1000);
    
  }  
}


Comments

  • edited 2013-05-26 23:29
    RCFAST isn't precise enough to send a serial message. Use a 5 MHz crystal, and set your board type to GENERIC. That'll run the system at 80 MHz, with precision to send serial messages. Since this is in a loop, you'll see the hello messages, but if it was just one, you'd want to put the pause before the printf.
  • sshaginyansshaginyan Posts: 9
    edited 2013-06-01 21:49
    I got a 8 MHz crystal and it started printing in SimpleIDE Terminal, however it's in Chinese. I know there is an extended ASCII table, but I'm pretty sure It should be printing in English. My baud rate is 115200 and the code is the same as above.
  • edited 2013-06-01 22:41
    It's probably because you are using an 8 MHz crystal instead of the 5 MHz crystal that was recommended.

    Try going into C:\propgcc\propeller-load
    Copy hub.cfg as custom.cfg.
    Open custom.cfg with a text editor and change the text to this, then save:

    # custom.cfg
    clkfreq: 64000000
    clkmode: XTAL1+PLL8X
    baudrate: 57600
    rxpin: 31
    txpin: 30

    I changed the baud rate to 57600. 115200 might work for both, not sure, so I decided to try lower since the 8 MHz crystal forces the system clock from 80 MHz to 64 MHz.

    [edit] Open boards.txt, note the pattern of .cfg files listed, and add a line for custom.cfg [/edit]

    After saving the file, if you are in Simple View, click the bottom-left Show Project Manager button (if it isn't already visible along the left). Then, click the puzzle piece next to the Board Type dropdown to refresh the list. Then, select Generic in the Board Type dropdown.

    Click Run with Terminal, and good luck...

    [edit] You might have to manually change that in Simple Terminal, then re-run so that the 57600 setting persists. [/edit]
  • sshaginyansshaginyan Posts: 9
    edited 2013-06-01 22:58
    I couldn't find an exact 5 MHz crystal, but I have a 4 MHz one. Would this be better? Also, would using a 8 MHz crystal break things. For example I've been trying to use pthreads, everything compiles and loads, but after calling pthread_create(&thread, NULL, monitor, NULL); the application just stops neither the functor is called nor the code continues within main.
  • edited 2013-06-02 00:34
    Well, what you've got is still worth a try. If you do, please let me know what the results were.

    Sounds like you can't get a 5 MHz oscillator. 4 MHz oscillator can only go up to 64 MHz because the Propeller chip's phase locked loop that generates the system clock can bump up the input frequency by up to 16x.

    5, 10, and 20 MHz oscillators are better values if the goal is to run the system clock at 80 MHz.

    The values you will update in custom.cft are PLL, clkfreq, and maybe XTAL. clkfreq = oscillator x PLLnX, where X can be 1, 2, 4, 8, or 16. Example: Oscillator is 10 MHz, so use PLL8X to run your system clock at 80 MHz (clkfreq: 80000000 in your .cfg file). XTAL1 is good up to 16 MHz, so you'd need to change to XTAL2 for a 20 MHz oscillator, and you'd also use PLL4X for clkfreq: 80000000.

    (XTAL values from Propeller Manual, page 68. Search www.parallax.com for Propeller Manual to find the download.)
  • sshaginyansshaginyan Posts: 9
    edited 2013-06-05 23:08
    Hey Andy my friend switched the crystal to a 5 MHz before I could test it. Sorry about that.
  • edited 2013-06-06 09:19
    No problem. With the 5 MHz crystal, you can just use the GENERIC board type without any modifications. If you changed the SimpleIDE Terminal's baud rate, make sure to change it back to 115200, and then everything should go smoothly.

    Andy
Sign In or Register to comment.