program stuck with stellaris LM2965
Greetings,
My name is Chris and I hve this CTL program running on my LM2965uC. The program sends a byte queue with a message which is then transferred on a CAN module. The problem is that after 13 or 14 sends, the program stucks. I've tried any ideals I had, and I'm also 100% sure that there is no problem on my hardware. I include and paste my program. Any help appreciated.
#include "includes.h"
#include <string.h>
#include <ctl_api.h>
#include "inc/hw_ints.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"
#include "inc/hw_gpio.h"
#include "inc/hw_memmap.h"
#include "inc/hw_can.h"
#include "driverlib/can.h"
#include "driverlib/interrupt.h"
#include "driverlib/systick.h"
#include "driverlib/pwm.h"
#include "rit128x96x4.h"
#include "ctl_can.h"
#include "utils/ringbuf.h"
#define E1 (1<<0)
#define E2 (1<<1)
#define E3 (1<<2)
#define E4 (1<<3)
#define E5 (1<<4)
#define E6 (1<<5)
#define CAN_BITRATE 250000
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifdef DEBUG
void
__error__(char *pcFilename, unsigned long ulLine)
{
}
#endif
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CTL_TASK_t main_task, new_task,CanTask,RecTask,StatusTask;
#define CALLSTACKSIZE 16 // this is only required for AVR builds
#define STACKSIZE 1000
CTL_EVENT_SET_t CANEVENT;
unsigned new_task_stack[1+STACKSIZE+1],CanTaskStack[1+STACKSIZE+1],RecTaskStack[1+STACKSIZE+1],
StatusTaskStack[1+STACKSIZE+1];
CTL_MUTEX_t mutex;
tRingBufObject ringbuffer;
unsigned char buffer_array[101];
unsigned char a[8];
char string[20];
//unsigned mem[8]/* = { 1, 2, 3, 4, 5, 6, 7, 8 }*/;
tCANMsgObject mem[9];
void *queue[9];
CTL_MEMORY_AREA_t mem1;
CTL_MESSAGE_QUEUE_t m1;
void *msg;
unsigned char pucMsgData[8] = {1,2,3,4,5,6,7,8};
/*-------------------------------------------------------------------------------------------------------------------------------*/
void TxTask(void *p)
{
tCANMsgObject* test;
while (1)
{
//14 küldés után megáll
tCANMsgObject MsgObjectTx;
RIT128x96x4StringDraw("Sending", 20, 24, 15);
ctl_message_queue_receive(&m1, (void **)&test, CTL_TIMEOUT_NONE, 0);
CANMessageSet(CAN0_BASE, 2, test, MSG_OBJ_TYPE_TX);
ctl_memory_area_free(&mem1, (unsigned*)test);
//ctl_timeout_wait(ctl_get_current_time()+1000);
}
}
/*-------------------------------------------------------------------------------------------------------------------------------*/
void MsgMake (void *p)
{
unsigned z;
tCANMsgObject* asda;
while (1)
{
tCANMsgObject MsgObjectTx;
MsgObjectTx.ulMsgID = 2;
MsgObjectTx.ulMsgIDMask = 0;
MsgObjectTx.ulFlags = MSG_OBJ_TX_INT_ENABLE;
MsgObjectTx.ulMsgLen = 8;
MsgObjectTx.pucMsgData = pucMsgData;
int q;
q = GPIOPinRead(GPIO_PORTG_BASE, GPIO_PIN_4);
if (q == 0)
{
asda = (tCANMsgObject*)ctl_memory_area_allocate( &mem1);
if (asda)
{
*asda=MsgObjectTx; //change asda.pucmsgdata[0]...
// ctl_message_queue_post(&m1, 1, CTL_TIMEOUT_NONE, 0);
ctl_message_queue_post(&m1, (void*)asda, CTL_TIMEOUT_NONE, 0);
}
}
ctl_timeout_wait(ctl_get_current_time()+100);
}
}
/*-------------------------------------------------------------------------------------------------------------------------------*/
void
ctl_handle_error(CTL_ERROR_CODE_t e)
{
while (1);
}
/*-------------------------------------------------------------------------------------------------------------------------------*/
int main(void)
{
INT32U s = sizeof(tCANMsgObject);
s = sizeof(unsigned);
SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
GPIODirModeSet(GPIO_PORTG_BASE, GPIO_PIN_4, GPIO_DIR_MODE_IN);
GPIOPadConfigSet(GPIO_PORTG_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
ctl_memory_area_init(&mem1,(unsigned*) mem, sizeof(tCANMsgObject)/sizeof(unsigned), 9);
ctl_message_queue_init(&m1, (void **)&queue, 24);
CAN_0_Init(CAN_BITRATE);
GPIODirModeSet(GPIO_PORTG_BASE, GPIO_PIN_4, GPIO_DIR_MODE_IN);
GPIOPadConfigSet(GPIO_PORTG_BASE, GPIO_PIN_4, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
ctl_events_init(&CANEVENT, 0);
ctl_mutex_init(&mutex);
RIT128x96x4Init(1000000);
ctl_task_init(&main_task, 255, "main"); // create subsequent tasks whilst running at the highest priority.
ctl_start_timer(ctl_increment_tick_from_isr); // start the timer
memset(new_task_stack, 0xcd, sizeof(new_task_stack)); // write known values into the stack
memset(CanTaskStack, 0xcd, sizeof(CanTaskStack));
new_task_stack[0]=new_task_stack[1+STACKSIZE]=0xfacefeed;
CanTaskStack[0]=CanTaskStack[1+STACKSIZE]=0xfacefeed;
// put marker values at the words before/after the stack
ctl_task_run(&new_task, 1, TxTask, 0, "sending", STACKSIZE, new_task_stack+1, CALLSTACKSIZE);
ctl_task_run(&CanTask, 1, MsgMake, 0, "creating msg", STACKSIZE, CanTaskStack+1, CALLSTACKSIZE);
ctl_task_set_priority(&main_task, 0); // drop to lowest priority to start created tasks running.
}
main_ctl.c
Please sign in to leave a comment.
Comments
0 comments