Pumpkin, Inc.

Pumpkin User Forums

Salvo

If you can't make Salvo do what you want it to do, post it here.

Salvo

Postby 1064453 » Tue Jun 06, 2006 12:09 am

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.


1064453
 
Posts: 25
Joined: Wed Nov 16, 2005 12:00 am

Re: Salvo

Postby 1064453 » Sat Jun 10, 2006 2:20 am

hi AEK:

Any advices for the problems?

1064453
 
Posts: 25
Joined: Wed Nov 16, 2005 12:00 am

Re: Salvo

Postby aek » Sat Jun 10, 2006 8:30 am

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.

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

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm

Re: Salvo

Postby 1064453 » Mon Jun 12, 2006 8:27 am

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

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

1064453
 
Posts: 25
Joined: Wed Nov 16, 2005 12:00 am

Re: Salvo

Postby 1064453 » Tue Jun 13, 2006 7:37 am

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).

1064453
 
Posts: 25
Joined: Wed Nov 16, 2005 12:00 am

Re: Salvo

Postby aek » Tue Jun 13, 2006 11:20 am

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).

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

-------
aek
aek
 
Posts: 1888
Joined: Sat Aug 26, 2000 11:00 pm


Return to Coding

Who is online

Users browsing this forum: No registered users and 1 guest

cron