Pumpkin, Inc.

Pumpkin User Forums

messages from ISR

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

Re: messages from ISR

Postby PresbyopticProgrammer » Tue Dec 11, 2007 1:09 am

crud (well, happy actually), I think I know what it is, how embarrassing...

the C8051F340 XRAM space has a portion chopped out for the USB FIFO, which you can use, but only if the USB clock is active (mine is not).

I cut it out using the linker locater and now it works just fine with messages from the ISR, and global buffers in the task.

Well, pretty sure that is it, sorry for the time, on to the next thing.

PresbyopticProgrammer
 
Posts: 14
Joined: Wed Nov 21, 2007 12:00 am
Location: Fort Valley, VA, USA

Re: messages from ISR

Postby aek » Tue Dec 11, 2007 1:42 am

Hey, that's the best news possible!

I'm glad it's figured out.

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

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

Re: messages from ISR

Postby PresbyopticProgrammer » Tue Dec 11, 2007 8:35 am

set optimization level to zero with no effect. same as with set to 8 (default).

here are the #defines to show you:

code:

//#define MSG_FROM_ISR
#define BINSEM_FROM_ISR
//#define GLOBAL_MSG_PUT
#define LOCAL_MSG_PUT

when I set like the above I get a hello world message every time I enter a line from the uart.

when I change defines above to use messages from isr the message says it fires in the isr but the echo test task never sees it.

_and_, when I change defines above to use the binsem in the isr but use the global buffer in the echo test task (so it actually echoes) then I never get a message output either.

only the above configuration (binsem in isr, local buffer in echo test task) seems to work.

here is declarations:

code:

#define TASK_PUTS_UART0_P OSTCBP(1)
#define TASK_PUTS_UART1_P OSTCBP(2)
// OSTCBP's(3 and 4) used for test tasks
#define PRIO_PUTS_UART0 10
#define PRIO_PUTS_UART1 10
#define MSG_PUTS_UART0_P OSECBP(1)
#define MSG_GETS_UART0_P OSECBP(2)
#define MSG_PUTS_UART1_P OSECBP(3)
#define MSG_GETS_UART1_P OSECBP(4)
#define BINSEM_PUTCHAR_UART0_P OSECBP(5)
#define BINSEM_PUTCHAR_UART1_P OSECBP(6)

char xdata rxUART0[BUFSZ_UART0_RX];
char xdata rxUART1[BUFSZ_UART1_RX];
bit rxOverrunUART0;
bit rxOverrunUART1;



here is echo task:

code:

void TaskTestEchoUART0() // Test only
{
char xdata aliveMessage[] = "Hello World!";
OStypeMsgP msgP;

OSSignalMsg(MSG_PUTS_UART0_P, (OStypeMsgP)aliveMessage);
for (; ;)
{
#ifdef MSG_FROM_ISR
OS_WaitMsg(MSG_GETS_UART0_P, &msgP, OSNO_TIMEOUT, TestEchoUART0_sw1);
#endif
#ifdef BINSEM_FROM_ISR
OS_WaitBinSem(MSG_GETS_UART0_P, OSNO_TIMEOUT, TestEchoUART0_sw1);
#endif
#ifdef GLOBAL_MSG_PUT
OSSignalMsg(MSG_PUTS_UART0_P, (OStypeMsgP)rxUART0);
#endif
#ifdef LOCAL_MSG_PUT
OSSignalMsg(MSG_PUTS_UART0_P, (OStypeMsgP)aliveMessage);
#endif
}
}


here is main:

code:

void main()
{
init();
OSInit();
OSCreateBinSem(BINSEM_PUTCHAR_UART0_P, 0);
OSCreateBinSem(BINSEM_PUTCHAR_UART1_P, 0);
OSCreateMsg(MSG_PUTS_UART0_P, (OStypeMsgP)0);
#ifdef MSG_FROM_ISR
OSCreateMsg(MSG_GETS_UART0_P, (OStypeMsgP)0);
#endif
#ifdef BINSEM_FROM_ISR
OSCreateBinSem(MSG_GETS_UART0_P, 0);
#endif
OSCreateMsg(MSG_PUTS_UART1_P, (OStypeMsgP)0);
OSCreateMsg(MSG_GETS_UART1_P, (OStypeMsgP)0);
OSCreateTask(TaskPutsUART0, TASK_PUTS_UART0_P, PRIO_PUTS_UART0);
OSCreateTask(TaskPutsUART1, TASK_PUTS_UART1_P, PRIO_PUTS_UART1);
OSCreateTask(TaskTestEchoUART0, OSTCBP(3), 10); // Test only
OSCreateTask(TaskTestBlinky, OSTCBP(4), 10); // Test only
OSEi();
for (; ;)
{
OSSched();
}
}

here is isr:

code:

void uart0isr() interrupt INTERRUPT_UART0
{
char data rxChar;
unsigned char data tempStrLen;

if (RI0)
{
rxChar = SBUF0;
RI0 = 0;
for (tempStrLen = 0; (rxUART0[tempStrLen] != '') || (tempStrLen >= sizeof(rxUART0)); tempStrLen++);
switch (rxChar)
{
case '
':
if (tempStrLen != 0)
{
if (OSReadMsg(MSG_GETS_UART0_P))
{
rxOverrunUART0 = 1;
}
else
{
#ifdef MSG_FROM_ISR
OSSignalMsg(MSG_GETS_UART0_P, (OStypeMsgP)rxUART0);
#endif
#ifdef BINSEM_FROM_ISR
OSSignalBinSem(MSG_GETS_UART0_P);
#endif
}
}
case ' ':
break;
default:
if (OSReadMsg(MSG_GETS_UART0_P) || (tempStrLen + 1 >= sizeof(rxUART0)))
{
rxOverrunUART0 = 1;
}
else
{
rxUART0[tempStrLen + 1] = '';
rxUART0[tempStrLen] = rxChar;
}
break;
}
}
if (TI0)
{
TI0 = 0;
OSSignalBinSem(BINSEM_PUTCHAR_UART0_P);
}
}



[This message has been edited by PresbyopticProgrammer (edited December 11, 2007).]

[This message has been edited by aek (edited December 11, 2007).]

PresbyopticProgrammer
 
Posts: 14
Joined: Wed Nov 21, 2007 12:00 am
Location: Fort Valley, VA, USA

Re: messages from ISR

Postby aek » Tue Dec 11, 2007 8:42 am

Can you post your salvocfg.h?

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

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

Re: messages from ISR

Postby PresbyopticProgrammer » Tue Dec 11, 2007 8:43 am

here is the whole salvocfg.h

#define OSUSE_LIBRARY TRUE
#define OSLIBRARY_TYPE OSL
#define OSLIBRARY_GLOBALS OSX
#define OSLIBRARY_CONFIG OSA
#define OSLIBRARY_VARIANT OSA
#define OSTASKS 4
#define OSEVENTS 6
#define OSBYTES_OF_DELAYS 1

PresbyopticProgrammer
 
Posts: 14
Joined: Wed Nov 21, 2007 12:00 am
Location: Fort Valley, VA, USA

Re: messages from ISR

Postby PresbyopticProgrammer » Tue Dec 11, 2007 8:45 am

btw thx for the edit help
how do I get the code codes to work?
is it <code>code here</code>?
guess not, will have to look up ubb codes

[This message has been edited by PresbyopticProgrammer (edited December 11, 2007).]

PresbyopticProgrammer
 
Posts: 14
Joined: Wed Nov 21, 2007 12:00 am
Location: Fort Valley, VA, USA

Re: messages from ISR

Postby PresbyopticProgrammer » Tue Dec 11, 2007 8:48 am

re the salvocfg.h... I also want to get 4 bytes of delays, but get a bunch of warnings and bad references when I try to define anything but 1 byte. maybe there is another switch I need?

but that is another issue for later down the road, first I need to figure out why this isr messaging is not working for me.

PresbyopticProgrammer
 
Posts: 14
Joined: Wed Nov 21, 2007 12:00 am
Location: Fort Valley, VA, USA

Re: messages from ISR

Postby aek » Tue Dec 11, 2007 8:49 am

One thing I just thought of ... signaling a message with 0 data is the same as not signaling it at all ... this is different from signaling a message queue ... but I don't think your code is susceptible to that.

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

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

Re: messages from ISR

Postby aek » Tue Dec 11, 2007 8:50 am

quote:
re the salvocfg.h... I also want to get 4 bytes of delays, but get a bunch of warnings and bad references when I try to define anything but 1 byte. maybe there is another switch I need?
The warnings are correct -- the library was built with 1-byte delays, and you can't force 4-byte delays onto it (without rebuilding the library). Your options are to build a custom library (very easy of you have e.g. Cygwin installed -- See Libraries chapter in user manual) or do a Pro build.

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

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

Re: messages from ISR

Postby PresbyopticProgrammer » Tue Dec 11, 2007 8:58 am

how does it know there is 0 data? you mean if you use a pointer to address zero?

because the format of the message the pointer points to is pretty much custom correct?

also, what do you mean by a "Pro build"? is that using Salvo Pro with a L (vs F) library?

(none of which is the issue here, but something good to know)

PresbyopticProgrammer
 
Posts: 14
Joined: Wed Nov 21, 2007 12:00 am
Location: Fort Valley, VA, USA

PreviousNext

Return to Coding

Who is online

Users browsing this forum: No registered users and 1 guest

cron