Comment fait tu pour détecter le FE (qui est le break de synchro) si tu as pas d’émetteur ?
Je vais formuler différemment, je n'ai pas de projo ni de consoles certifiés DMX, j'ai écrit un code pour emettre du DMX, et un autre pour recevoir, mais c'est pas le bon plan puisque je ne suis pas sur qu'un des deux soient conforme à la norme
avec ce code j'ai eu des résultats en utilisant le MEME chip et en reliant l'UART1 à l'UART2 et il avait l'air de se passer des trucs (le framing error était synchro avec le break) mais en utilisant le même code en ne gardant que le Transmit pour l'un et le Receive pour l'autre plus rien... quelque chose me dit que l'oscillateur interne y est pour quelque chose, je sais, c'est MAL

mais je viens de choper 2 quartz 16 MHz donc je vais pouvoir être plus précis
Code: Select all
#include <main.h>
#define BREAK_TIME 88 // BREAK = 88us
#define MAB_TIME 8 // MARK AFTER BREAK = 8us
#define DMX_START_CODE 0x00 // START CODE = 0 typical. other statement are reserved.
#define DMX_BREAK setup_uart (FALSE,DMX); output_low (PIN_C6); delay_us (BREAK_TIME); // Generate a LOW LEVEL on Tx PIN
#define DMX_MAB output_high (PIN_C6); delay_us (MAB_TIME); // Generate an HIGH LEVEL on Tx PIN
#define DMX_START_CODE setup_uart (TRUE,DMX); putc (START_CODE,DMX); // Send the code 0x00 on the UART
#define FRAMING_ERROR (RS232_ERRORS & 0x04)==0x04 // Detecting framing error for 88µs DMX break detection
char dmx_trame [513]; // 0 to 512, 0 => Start code, 1 - 512 => DMX data bytes
int16 dmx_channel; // byte/channel number : 0 to 512
int16 ptr_buffer; // poiter to "dmx_trame [x]"
int16 dmx_address=0; // Set the DMX receiver address
int start_code; // Start code, expect 0x00 when tested
int channel_1; // DMX receiver channel 1, idependent of DMX address number
int channel_2; // DMX receiver channel 2, idependent of DMX address number
int channel_3; // DMX receiver channel 3, idependent of DMX address number
int u1; // User data value for channel 1
int u2; // User data value for channel 2
int u3; // User data value for channel 3
#int_RDA2 // DMX RECEIVER interrupt
void RDA2_isr(void)
{
dmx_trame [ptr_buffer] = getc (UART); // Receiving data
ptr_buffer++; // go to next byte
if (FRAMING_ERROR) // Detection of DMX Break (88µs à '0')
{
ptr_buffer=0; // Re-init DMX trame
output_high (PIN_B5); // LED for test/debug
delay_us (25); // LED for test/debug
output_low (PIN_B5); // LED for test/debug
}
}
void main()
{
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_timer_3(T3_INTERNAL | T3_DIV_BY_1);
setup_timer_4(T4_DIV_BY_1,0,1);
setup_ccp1(CCP_PWM|CCP_SHUTDOWN_AC_L|CCP_SHUTDOWN_BD_L|CCP_USE_TIMER3_AND_TIMER4);
setup_ccp2(CCP_PWM|CCP_SHUTDOWN_AC_L|CCP_SHUTDOWN_BD_L|CCP_USE_TIMER3_AND_TIMER4);
setup_ccp3(CCP_PWM|CCP_SHUTDOWN_AC_L|CCP_SHUTDOWN_BD_L|CCP_USE_TIMER3_AND_TIMER4);
enable_interrupts (INT_RDA2);
enable_interrupts (GLOBAL);
while(TRUE)
{
dmx_address=0; // Set the DMX address from 0 to 508 (1 to 509)
u1=0x00; // Adjust manually the value or link it to a 8 bits ADC
u2=0xff; // Adjust manually the value or link it to a 8 bits ADC
u3=0xff; // Adjust manually the value or link it to a 8 bits ADC
/******************************************************************************/
/************************* DMX TRANSMITTER ************************************/
/******************************************************************************/
if (dmx_channel==0 || dmx_channel==512) // Beginning of a new DMX trame
{
dmx_channel=0; // Re-init DMX byte/channel number
DMX_BREAK; // Send a break : send a LOW level during 88µs
DMX_MAB; // Send an HIGH level during 8µs
DMX_START_CODE; // Send 0x00
dmx_channel++; // increment dmx_channel => dmx_channel=1
}
putc ((u1),DMX); // transmit the first data byte
putc ((u2),DMX); // transmit the second data byte
putc ((u3),DMX); // transmit the third data byte
// you can add as channel as you want on [1-512] range
/******************************************************************************/
/************************* DMX RECEIVER ***************************************/
/******************************************************************************/
dmx_channel++; // go to next data byte
start_code = dmx_trame [0]; // receive Start code
channel_1 = dmx_trame [1 + dmx_address]; // receive 1st data byte
channel_2 = dmx_trame [2 + dmx_address]; // receive 2nd data byte
channel_3 = dmx_trame [3 + dmx_address]; // receive 3rd data byte
set_pwm1_duty((int)channel_1); // Blue LED output
set_pwm2_duty((int)channel_2); // Red LED output
set_pwm3_duty((int)channel_3); // Green LED output
}
}
Code: Select all
#include <18F46K22.h>
#device ICD=TRUE
#device adc=16
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOBROWNOUT //No brownout reset
#FUSES WDT_NOSLEEP //Watch Dog Timer, disabled during SLEEP
#FUSES NOPBADEN //PORTB pins are configured as digital I/O on RESET
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES DEBUG //Debug mode for use with ICD
#FUSES CCP3E0 //CCP3 input/output multiplexed with RE0
#use delay(int=64000000)
#use rs232(baud=250000,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=DMX,stop=2,brgh1ok)
#use rs232(baud=250000,parity=N,xmit=PIN_D6,rcv=PIN_D7,bits=8,stream=UART,stop=2,brgh1ok,errors)
// Don't forget to link PIN_C6 with PIN_D7