Re: 5234 eTPU code for QOM module?
Posted: Tue May 08, 2012 8:09 am
Your code work on my setup. Rel_2_5_2.
Just in case I will copy everything:
Just in case I will copy everything:
Code: Select all
#include "predef.h"
#include <stdio.h>
#include <ctype.h>
#include <startnet.h>
#include <autoupdate.h>
#include <dhcpclient.h>
#include <smarttrap.h>
#include <taskmon.h>
#include <NetworkDebug.h>
#include <etpu_util.h>
#include <pins.h>
#include <eTPUinit.h>
#include <eTPU.h>
#include <etpu_qom.h>
#include <sim5234.h>
extern "C"
{
void UserMain(void * pd);
}
const char * AppName="testQOM";
void UserMain(void * pd)
{
InitializeStack();
if (EthernetIP == 0) GetDHCPAddress();
OSChangePrio(MAIN_PRIO);
EnableAutoUpdate();
EnableTaskMonitor();
#ifndef _DEBUG
EnableSmartTraps();
#endif
#ifdef _DEBUG
InitializeNetworkGDB_and_Wait();
#endif
iprintf("Application started\n");
eTPUInit(); // Standard init for ETPU, puts all channels in hiz (inputs)
int on_time_t = 36864 ; //(1 msec => (1000 usec * etpu_a_tcr1_freq) / 1000000;
union etpu_events_array my_event_array[2] =
{
{(0x00000 << 1) + FS_ETPU_PIN_HIGH}, // pin goes hi
{(on_time_t << 1) + FS_ETPU_PIN_LOW} // len lo after on_time_t
};
while ( 1 )
{
J2[7] = 1; // Use J2[7] to trigger scope. QOM Pulse on J2[9] should follow it.
int result = fs_etpu_qom_init(5,
FS_ETPU_PRIORITY_HIGH,
FS_ETPU_QOM_SINGLE_SHOT,
FS_ETPU_TCR1,
FS_ETPU_QOM_INIT_PIN_LOW,
FS_ETPU_QOM_IMMEDIATE,
(uint32_t *) 0,
0,
2,
my_event_array);
OSTimeDly( 1 );
iprintf("etpu 5 ret val = %d, ontime = 0x%x, = %d\n", result, on_time_t, on_time_t);
J2[7] = 0; // reset J2[7]
OSTimeDly( 1 );
OSTimeDly(TICKS_PER_SECOND);
}
}