• AVR Freaks

Hot!UART and GRAPHICS conflict (Maybe)... I am DESPERATE for help!

Author
Al.THz
New Member
  • Total Posts : 18
  • Reward points : 0
  • Joined: 2012/04/04 22:18:06
  • Location: Southwest Ontario Canada
  • Status: offline
2012/11/24 11:23:09 (permalink)
0

UART and GRAPHICS conflict (Maybe)... I am DESPERATE for help!

Hardware:
PIC24FJ256DA210 Dev Board
TFT_G240320LTSW_118W_E
Parallax 125kHz RFID Reader for EM4100 Tags (RS232/2400bps/8 bit/No Parity/One stop) Enable/Disable done with port latches
Software:
MPLAB IDE v8.63
C30 Compiler
Microchip Solutions v2010-10-19 (Graphics Library - Primitive_Layer_Demo) <== The newer versions want a compiler I do not have
UART_Demo from Code Examples - Document 'CE333'  <== For a different PIC but just changed the device, compiled and worked.
 
So here is the situation....
I programed the controllers UART2 alone using a UART demo from the MC website, I was able to receive correct tag info, no problems.
I programed the controllers GRAPHICS alone using the Primitive_Layer_Demo in the Graphics Library, I was able to draw lines/circles/text/etc, no problems.
I used the same Primitive_Layer_Demo and added the same configuration for UART from the UART_Demo, with the exception of the pin that RX was routed to via PPS due to the graphics needing that pin.
I also copied the same interrupt routine from UART_Demo into the Primitive_Layer_Demo
It compiles with no errors, interrupts when I set a tag on the reader, reads the RXREG and stores info fine....but.
The info it is reading is all 0x00FF with the occasional 0x00BF or 0x00F7
I have gone through the demo and commented out everything that wasn't pertaining to this DEV_BOARD, compiles fine, no change.
I have tried changing the RX pin to many others RP10/14/17/22/more, with no change.
I have played with the U2MODE; U2STA; U2BRG registers trying different configurations, I changed BRG thinking that the graphics config messed around with the oscillator scaler, I tried 32MHz/16MHz/8MHz, but should be 4MHz I think.
I also copied the oscillator settings from the UART_DEMO (hoping that worst case the RFID would start working and graphics would stop), no change.
 
I am sure there is some more information that would be helpful, I will obviously provide if someone can help
 
MainDemo.c <== I deleted all the stuff I commented out and my functions I wasn't using while debugging this prob, just for shortness and clarity.

/*****************************************************************************
 * Microchip Graphics Library Demo Application
 * This program shows how to use the Graphics Primitives Layer.
 *****************************************************************************
 * FileName:        MainDemo.c
 * Dependencies:    MainDemo.h
 * Processor:       PIC24F, PIC24H, dsPIC, PIC32
 * Compiler:           MPLAB C30, MPLAB C32
 * Linker:          MPLAB LINK30, MPLAB LINK32
 * Company:         Microchip Technology Incorporated
 
 * Author               Date        Comment
 *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 * Anton Alkhimenok        30/05/07    ...
 *****************************************************************************/
#include "MainDemo.h"
#include "uart.h"
#include "PPS.h"


    #if defined (__PIC24FJ256DA210__)
_CONFIG1( WDTPS_PS32768 & FWPSA_PR128 & ALTVREF_ALTVREDIS & WINDIS_OFF & FWDTEN_OFF & ICS_PGx2 & GWRP_OFF & GCP_OFF & JTAGEN_OFF)
_CONFIG2( POSCMOD_HS & IOL1WAY_OFF & OSCIOFNC_OFF & OSCIOFNC_OFF & FCKSM_CSDCMD & FNOSC_PRIPLL & PLL96MHZ_ON & PLLDIV_DIV2 & IESO_OFF)
_CONFIG3( WPFP_WPFP255 & SOSCSEL_SOSC & WUTSEL_LEG & ALTPMP_ALTPMPEN & WPDIS_WPDIS & WPCFG_WPCFGDIS & WPEND_WPENDMEM)
    #endif


int temp,counter1,counter2,a;        //These are used in the delay subroutine
unsigned short RxFrame[36];            //Set an array of 36 bytes for recieving even though we only need 12
int ActiveTag[12];
int RxCounter,j,t;                    //Counter for storing received info and not sure what j is
int RxFlag = 0;                        //Creating a flag for processing a complete transmission
int    Tag = 1;
int LaneRes = 32;
int LineZero = 0;
int LineOne = 0;
int LineTwo = 0;
int TagPos = 1;
int OXone = 80;
int OYone = 0;
int OXtwo = 240;
int OYtwo = 0;
int Hx = 160;
int Hy = 120;

void TagDefinition(void);
void FindLines(void);
void DrawLines(void);

int main(void)
{
    //********************** Assign UART 2 signals onto pins using PPS ***********************************
    iPPSInput(IN_FN_PPS_U2RX,IN_PIN_PPS_RP22);        //Assing U2RX to pin RP10
    //iPPSInput(IN_FN_PPS_U2CTS,IN_PIN_PPS_RPI32);    //Assing U2CTS to pin RP32
    //iPPSOutput(OUT_PIN_PPS_RP17,OUT_FN_PPS_U2TX);    //Assing U2TX to pin RP17
    //iPPSOutput(OUT_PIN_PPS_RP31,OUT_FN_PPS_U2RTS);    //Assing U2RTS to pin RP31
   
    //CloseUART2();                                      //dsiable UART if enabled previously       
   
    InitGraph();
/*********************** UART 2 Configuration ****************************************************
*        2400 baudrate
*        Low baud rate
*        8 bit transmission/reception
*        No parity bit
*        1 stop bit
************************************************************************************************/   
    /*Enable UART intruupts*/       
    ConfigIntUART2(UART_RX_INT_EN |UART_RX_INT_PR7| UART_TX_INT_DIS);
    OpenUART2(0x8800, 0x8000, 103);            //configure UART and enable it
    

    while(1)
    {
        //Line(80,40,260,200); //just for testing

        if(RxFlag==1)
        {
            //TagDefinition();
            //FindLines();
            //DrawLines();
            RxFlag=0;
        }

        //RxFlag=0;
        //ClearDevice();  //I don't this can't be done in the while loop, test later
    }
}


//*************** Interrupt Service routine for UART2 reception *************************************
void __attribute__ ((interrupt,no_auto_psv)) _U2RXInterrupt(void)
{
        RxFrame[RxCounter] = ReadUART2();    //Read the data from UART buffer
        RxCounter++;
 
        if(RxCounter==36)
        {
            RxFlag=1;
            RxCounter=0;
        }

        U2RX_Clear_Intr_Status_Bit;
}

#1

3 Replies Related Threads

    Mike017
    Super Member
    • Total Posts : 2698
    • Reward points : 0
    • Joined: 2007/08/25 08:11:31
    • Location: Lincoln, RI, USA
    • Status: offline
    Re:UART and GRAPHICS conflict (Maybe)... I am DESPERATE for help! 2012/11/25 14:21:05 (permalink)
    0
    Hi,
     
    I have played with the U2MODE; U2STA; U2BRG registers trying different configurations, I changed BRG thinking that the graphics config messed around with the oscillator scaler, I tried 32MHz/16MHz/8MHz, but should be 4MHz I think.
    Compare the oscillator config settings of both code examples. Any change in the oscillator settings in the UART code will guarantee garbage characters. Use the formula to find the correct BAUD settings.  
     
    Good Luck,
    Mike
    #2
    kanchasa
    New Member
    • Total Posts : 1
    • Reward points : 0
    • Joined: 2019/12/04 18:30:50
    • Location: 0
    • Status: offline
    Re: UART and GRAPHICS conflict (Maybe)... I am DESPERATE for help! 2019/12/05 10:45:54 (permalink)
    0
    Hi AI.Thz,
     
    I am facing the same issue right now.Could you please help me out with the conflict between graphics and UART.
     
     
    #3
    ric
    Super Member
    • Total Posts : 25101
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: online
    Re: UART and GRAPHICS conflict (Maybe)... I am DESPERATE for help! 2019/12/05 14:41:25 (permalink)
    0
    This is a seven year old topic, and that specific user has not logged in since 2015.
    You would do better to start your own topic, and fully describe your own situation.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #4
    Jump to:
    © 2020 APG vNext Commercial Version 4.5