CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC24 DMX BREAk PROBLEM

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Roberto da Rivoli



Joined: 09 Feb 2004
Posts: 37
Location: TURIN -Italy-

View user's profile Send private message Send e-mail

PIC24 DMX BREAk PROBLEM
PostPosted: Fri Nov 14, 2014 5:41 am     Reply with quote

Help I have a problem with UART1 pic24FV, I can not catch the error in a frame break DMX Sad
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Nov 14, 2014 6:02 am     Reply with quote

Help us help you !
Show us a small,compilable program that fails the way you say. Also include type of PIC and compiler version.
I'm assuming your PIC is a 'slave' and not the 'master' in your project ?

Jay
Roberto da Rivoli



Joined: 09 Feb 2004
Posts: 37
Location: TURIN -Italy-

View user's profile Send private message Send e-mail

PostPosted: Fri Nov 14, 2014 7:08 am     Reply with quote

I'm using pic24FV32KA304 (32Mhz) compiler PCD 5,025 in this application is a DMX slave reception only by professional console
the problem is that enabling the interrupt error:
Code:

#use rs232 (UART1, baud = 250000, restart_wdt, STOP = 2 errors, stream = UART_PORT1)

enable_interrupts (INT_UART1E);
enable_interrupts (INTR_GLOBAL);

# INT_UART1E
uart1e_isr void (void)
{
clear_interrupt (INT_UART1E);

   big head = 1;
}

Putting a break point on
big head = 1;
  to stop the program only the first time
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Nov 14, 2014 7:16 am     Reply with quote

1) you're missing the comma in front of 'errors' in the USE rs232(...options). might be a problem

2) You don't need to clear the interrupt in the ISR, CCS does that for you.

3) be careful about using 'restart_wdt'. It could cause 'problems'. Usually you enable WDT software once the whole porgram is 'up and running' 100% after a lot of testing.

4) you've only given us a few lines, not 'real code' so we can't 'cut/paste/test'.

hth
jay
Roberto da Rivoli



Joined: 09 Feb 2004
Posts: 37
Location: TURIN -Italy-

View user's profile Send private message Send e-mail

PostPosted: Fri Nov 14, 2014 7:28 am     Reply with quote

Sorry if there is not the whole code, I can create a new program, since this is just the extract of a much more complex structure of about 20 files

I tried the fixes that you suggested but I have not solved anything

Code:
#include "../GENERAL/global.h"
/*-----------------------------------------------------------------------------
 * main()
*/
void StampaVideo(char *a,uint8 nun_char);



uint8 testone=0;
void main()
{
init_system();      // init SYStem

#use rs232(UART1, baud=250000, STOP=2, stream=UART_PORT1)
enable_interrupts(INT_UART1E);
enable_interrupts(INTR_GLOBAL);



while(TRUE){
  Gest_PULS();
  Leisurely();
}//END while


} // END main


#INT_UART1E
void  uart1e_isr(void)
{
  testone=1;
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Fri Nov 14, 2014 7:45 am     Reply with quote

The key thing is as temtronic says, to properly add the 'ERRORS' keyword to the RS232 declaration. This then tells the compiler to add 'error' handling code.

It needs to be:

#use rs232(UART1, baud=250000, STOP=2, stream=UART_PORT1, ERRORS)

Then if you look at the variable 'RS232_ERRORS', it will have bits set corresponding to the various UART errors. What you want will be the FERR bit (bit 2)

So:
Code:

#define FERR bit_test(RS232_ERRORS,2)

//then in the receive interrupt
//get your character _first_ must always be done

   if (FERR)
   {
      //do what you want for the error
   }


also, _critical_ that you do a getc, in the receive interrupt. The interrupt _cannot be cleared_ till this is done.
Roberto da Rivoli



Joined: 09 Feb 2004
Posts: 37
Location: TURIN -Italy-

View user's profile Send private message Send e-mail

PostPosted: Fri Nov 14, 2014 8:00 am     Reply with quote

I have tested your solution, but it does not work in another project which uses a PIC16 use your method and everything works fine, now I have big problems with the PIC24FV
Roberto da Rivoli



Joined: 09 Feb 2004
Posts: 37
Location: TURIN -Italy-

View user's profile Send private message Send e-mail

PostPosted: Fri Nov 14, 2014 8:19 am     Reply with quote

I am convinced that the solution to Ttelmah is correct, as I am convinced that the DMX signal I'm sending to the serial port 1 is correct, I'm checking with the oscilloscope, but looking at the log below the FERR event never occurs


U1MODE 220 11000X0000000001 0xC001
U1STA 222 000X010100010011 0x0513
U1TXREG 224 XXXXXXX000000000 0x0000
U1RXREG 226 XXXXXXX000000000 0x0000
U1BRG 228 0000000000000011 0x0003


STSEL 220.0 1
PDSEL 220.1-2 0
BRGH 220.3 0
RXINV 220.4 0
ABAUD 220.5 0
LPBACK 220.6 0
WAKE 220.7 0
UEN 220.8-9 0
RTSMD 220.11 0
IREN 220.12 0
USIDL 220.13 0
UFRZ 220.14 1
UARTEN 220.15 1
URXDA 222.0 1
OERR 222.1 1
FERR 222.2 0
PERR 222.3 0
RIDLE 222.4 1
ADDEN 222.5 0
URXISEL 222.6-7 0
TRMT 222.8 1
UTXBF 222.9 0
UTXEN 222.10 1
UTXBRK 222.11 0
UTXISEL 222.13 0
UTXINV 222.14 0
UTXISEL1 222.15 0
UTXREG 224.0-8 0
URXREG 226.0-8 0
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Fri Nov 14, 2014 8:53 am     Reply with quote

The receiver is shown as IDLE (nothing being received at present), but with an OVERRUN error (byte was not read from the UART in time).
Roberto da Rivoli



Joined: 09 Feb 2004
Posts: 37
Location: TURIN -Italy-

View user's profile Send private message Send e-mail

PostPosted: Fri Nov 14, 2014 9:16 am     Reply with quote

ok MR Ttelmah YOU HAVE REASON
I introduced a piece of program to empty the receive buffer and can intercept the break.

thanks so much
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group