Page 1 of 1

Salvo

PostPosted: Tue Jun 06, 2006 12:09 am
by 1064453
for pic16f877 and htsoft

1. WHy am I not able to output to rs232 serial port?
#include <salvo.h>
#include <main.h>
_OSLabel(TaskUART1)

void TaskUART(void)
{
int j=0;
for (;
{
char data[10]={1,2,3,4,5,1,2,3,4,5};

for ( j =0; j <10 ;j ++)
{
TXREG = data[j];
}
OS_Yield(TaskUART1);
}

}

void main (void)
{

TXSTA = 0b10100100;
SPBRG = 0x81;
TRISC6=0;
TRISC7 = 1;
OSInit();
OSCreateTask(TaskUART,OSTCBP(1),1);

for (;
OSSched();

}


2. Do I need to include main,h everytime?
The main.h is from the Salvo tutorial.

TQ.



Re: Salvo

PostPosted: Sat Jun 10, 2006 2:20 am
by 1064453

hi AEK:

Any advices for the problems?


Re: Salvo

PostPosted: Sat Jun 10, 2006 8:30 am
by aek
You haven't provided enough information for me to help. This is something you can debug yourself.

To debug something like this, you should:

1) Put a breakpoint on the

code:
TXREG = data[j];

line. Do you reach that line over and over?

If yes, then the scheduler is working and your PIC-specific code (which is independent of Salvo) is the problem.

If no, then you probably haven't configured salvo properly (must look at your salvocfg.h).

2) The data you are trying to send are non-ASCII control characters, which won't show up on a terminal window anyway. You need this:

code:
 char data[10]={'1','2','3','4','5','1','2','3','4','5'};

That should get you started.

When trying some new code like this, I would recommend that you get the code working without Salvo first, so that you know that the serial comms are correct. Then keep that project, and create a new project that uses the same code, but with tasks this time.

------------------


Re: Salvo

PostPosted: Mon Jun 12, 2006 8:27 am
by 1064453
You haven't provided enough information for me to help. This is something you can debug yourself.
To debug something like this, you should:

1) Put a breakpoint on the

code:
--------------------------------------------------------------------------------

TXREG = data[j];

--------------------------------------------------------------------------------

line. Do you reach that line over and over?
If yes, then the scheduler is working and your PIC-specific code (which is independent of Salvo) is the problem.

****************************************
******Yes, in MPLAB simulator the number
output to TXREG repeatedly.

If no, then you probably haven't configured salvo properly (must look at your salvocfg.h).
*****************************************
****salvocfg.h

#define SYSA
#define OSUSE_LIBRARY TRUE
#define OSLIBRARY_TYPE OSF
#define OSLIBRARY_CONFIG OSA
#define OSLIBRARY_VARIANT OSA

***************************************


2) The data you are trying to send are non-ASCII control characters, which won't show up on a terminal window anyway. You need this:

code:
--------------------------------------------------------------------------------

char data[10]={'1','2','3','4','5','1','2','3','4','5'};


********************
******Changed alreay, but still cannot output

--------------------------------------------------------------------------------


Re: Salvo

PostPosted: Tue Jun 13, 2006 7:37 am
by 1064453

Hi AEK:


I hv gotten the output to my
hyperterminal already. Need to change the
OSC from RC to XT during programming.
TQ.

--------------------
OK, I haven't used the MPLAB SIM to do serial comms, but it is very useful for timing, verifying task functions, etc.
In your application, you yield back to the same task. This means that the transmit register is being filled with the new characters as fast as possible -- probably much faster than the baud rate allows. Use MPLAB's stopwatch to see how many cycles are between successive writes to TXREG.

If, for example, you're running at 9600bps, then you can't write to TXREG faster than every 105us (assuming 8, N, 1).


Re: Salvo

PostPosted: Tue Jun 13, 2006 11:20 am
by aek
OK, I haven't used the MPLAB SIM to do serial comms, but it is very useful for timing, verifying task functions, etc.

In your application, you yield back to the same task. This means that the transmit register is being filled with the new characters as fast as possible -- probably much faster than the baud rate allows. Use MPLAB's stopwatch to see how many cycles are between successive writes to TXREG.

If, for example, you're running at 9600bps, then you can't write to TXREG faster than every 105us (assuming 8, N, 1).

------------------