This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2530: Testing the UART

Other Parts Discussed in Thread: CC2530

 

I ran the following program after connecting the CC2530 module to the computer's serial port to test the UART functionality.

 

 

#include<iocc2530.h>

void main()

{

  U0CSR |= 0x80; //UART mode selected for USART0.

  U0UCR &= ~0x40; //H/w flow control disabled.

  PERCFG &= ~0x01; //Alernative 1 selected for UART0 peripheral.

  P0SEL |= 0x0C; //P0.2 and P0.3 peripheral mode enabled.

  U0GCR |= 0x08; U0BAUD = 0x3B; //Baud rate set to 9600 bps.

    U0DBUF=0x56;

   U0DBUF='A';

    U0DBUF='D';

    U0DBUF='V';

}

 

 

I was expecting the ASCII characters assigned to U0DBUF to be printed but the output on the terminal was just a bunch of question marks as seen in screenshot 1.

 

Screenshot 2 shows the register status post execution of the main() routine.

Somebody help me debug this please.

 

.

 

  • Hi John,

    Just a quick comment,

    once you load the value in UxDBUFF, wait for byte to tansmited.

    You can have busy wait loop i.e. while(!UTX0IF); or check 'TX_BYTE' flag

    Secondly your problem seems to be in baud rate mismatch.

    You haven't initialized the clock, use script below to initialize clock before initializing UART and check

    CLKCONCMD = CLKCONSTA & 0xB8;

      while(CLKCONSTA & 0x40);

    i check your code with thsi and it worked. check and verify


     


  • Hi John,

     

    Additionally to Muhammad's post, you may refer to "Using UART" - DN0112.

  • I am also trying to test my UART. I have used the code above with Muhammad's proposed changes. The code is shown below. I have it set up with a CC2530 on a SmartRF05 EB. The board is connected to the computer through a serial port. When I write the characters I read nothing over the serial port. I have double checked the baud rate and have read through the DN112. However, before I incorporate all of the code in the design note, I was hoping to have something coming over the serial port. In addition, the RS232 is enabled and I switched to using Docklight as John did in hopes of receiving something over the serial port with no luck. Does anyone have any suggestions?

    void sendChar()
    {

    CLKCONCMD = CLKCONSTA & 0xB8;
    while(CLKCONSTA & 0x40);

    U0CSR |= 0x80; //UART mode selected for USART0.

    //U0UCR &= ~0x40; //H/w flow control disabled.

    PERCFG &= ~0x01; //Alernative 1 selected for UART0 peripheral.

    P0SEL |= 0x0C; //P0.2 and P0.3 peripheral mode enabled.

    U0GCR |= 0x08; U0BAUD = 0x3B; //Baud rate set to 9600 bps.

    UTX0IF = 0;
    U0DBUF='H';
    while(!UTX0IF);
    UTX0IF = 0;

    U0DBUF='E';
    while(!UTX0IF);
    UTX0IF = 0;

    U0DBUF='L';
    while(!UTX0IF);
    UTX0IF = 0;

    U0DBUF='L';
    while(!UTX0IF);
    UTX0IF = 0;

    U0DBUF='O';
    while(!UTX0IF);
    UTX0IF = 0;
    }
    Thanks for any help,
    Katie
  • Hi Katie,

    Have you disabled HW flow control on the PC side?

  • That fixed it! Thank you so much for your quick response and help.

  • hi

    i was running your code....it was compiled properly but upon debuging it gives erro of "no targer selected" while i have done settings for target as

    upon debuging following window open up

    plz reply

    i have connected serial port of PC to cc2530EB directly.....

    regards

  • Hi,

    The error occurring immediately after the download complete?

  • no upon clicking for download and debug.... this error is shown.....with windows shown above in last post......actually we can download and debug using usb ports.....but for using RS232 DB -9 DOWNLOADING gives error.......ie "target not selected"

    while i have selected target as cc2530f 256......

    reply plz...how to solve...we need serial port in our project.....actually serial port is not identified.....

    do tell any guide???

    do we need to run SBL loader....or any other program for serial port....

    regards

  • Hi,

    You can debug only through CC debugger or smartRF05EBs like devices which are connected to PC with USB.

    There is no such option of debugging a target through serial port. At least if you haven't designed your own debugger.

    You can also download a binary file through the serial port if you have preprogrammed your target with a Serial Boot Loader

    (aka SBL)

  • thanks alot....for reply...

    then how to see data on hyper terminal???

    above program does not give any data on hyperterminal.....what does binary file men in zigbee???

  • You can use the "seralApp" example for achieving communication through the UART,

    however if you will try to catch this communication in hyper terminal you'll see a lot of

    gibberish. I don't remember what should be done in order to see a clear trace of serial

    comm in hyper terminal, but you can search in this forum for solution, I know there must

    be at least one.

    final year students said:
    .what does binary file men in zigbee

    Regarding this one, you can download new/modified FW into your target through SBL,

    for this you should generate a special form of binary file, though it is not directly related

    to the serial communication topic, you can read about it in the following guide:

    ...\Documents\CC2530\Serial Boot Loader for CC253x.pdf

  • thanks alot for reply.......