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

usb 18f26j50
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
alan



Joined: 12 Nov 2012
Posts: 358
Location: South Africa

View user's profile Send private message

PostPosted: Sun Dec 27, 2015 3:05 pm     Reply with quote

UART2 normally uses int rda2

Regards
sebalitter



Joined: 05 May 2015
Posts: 47

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

PostPosted: Thu Dec 31, 2015 10:18 am     Reply with quote

alan wrote:
UART2 normally uses int rda2

Regards


you are right, i miss the ports, C6 and C7 are from UART1, i changed now but still don't work.

Code:


#PIN_SELECT U2TX=PIN_C6
 #PIN_SELECT U2RX=PIN_C7
 #USE RS232(UART1,ERRORS,BAUD=9600,STREAM=WIFI,ERRORS)


Ttelmah



Joined: 11 Mar 2010
Posts: 20061

View user's profile Send private message

PostPosted: Thu Dec 31, 2015 3:50 pm     Reply with quote

I'm surprised the compiler doesn't complain about this.

TX1, and RX1, are not relocatable.

Repeat 50*. "You can _only_ use 'select' statements on peripherals that are relocatable"....

UART1, just needs:
Code:

#USE RS232(UART1,ERRORS,BAUD=9600,STREAM=WIFI,ERRORS)

INT_RDA1
//and the code in this must fgetc from 'WIFI'

For UART2, you have to select the pins, and the pins used must be RP pins.

Look at table 10-13 in the data sheet, which shows what input devices can be relocated, and 10-14, which shows the relocatable output devices.

It's honestly getting like trying to pull teeth using a pair of tweezers....
temtronic



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

View user's profile Send private message

PostPosted: Thu Dec 31, 2015 5:12 pm     Reply with quote

It's gotta be a 'net' thing..seems no one actually gets real, hard copy books and reads them cover to cover anymore......

Jay
sebalitter



Joined: 05 May 2015
Posts: 47

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

PostPosted: Sat Jan 02, 2016 8:36 am     Reply with quote

I will pay more attention to the documentation.

The console display wrong or even connect to uart.


- get mac
Mac Addr=00:06:66:9c:

- $$$
ERR: ?-Cmd
<4.41>

- get ip
IF=UP
DHCP=SERVER
IP2TG

get ip
IF=UP
DHCP=SERVER
IP2TG

- get ssid
SleepTmr=0
WakeTmr=oxb

sometimes the first legend is
&«Kc#Ó&‹VvƦ
otrers:
server init

This is the code. Not always work.


Code:


#include <18F26J50.h>
 #include <string.h>
 #include <ctype.h>


 #FUSES NOWDT
 #FUSES NODEBUG
 #FUSES NOXINST
 #FUSES NOPROTECT
 #FUSES NOFCMEN
 #FUSES NOIESO
 #FUSES NOCPUDIV
 #FUSES HSPLL
 #FUSES PLL3
 #FUSES RTCOSC_INT

 #use delay(crystal=12Mhz, clock=48Mhz)

 #USE RS232(UART1,ERRORS,BAUD=9600,STREAM=WIFI,ERRORS)
 
 #include <usb_cdc.h>

 #define BUFFER_SIZE 32
 BYTE buffer[BUFFER_SIZE];
 BYTE next_in = 0;
 BYTE next_out = 0;

 #int_rda
 void serial_isr() {
    int t;

    buffer[next_in]=fgetc();
    t=next_in;
    next_in=(next_in+1) % BUFFER_SIZE;
    if(next_in==next_out)
      next_in=t;           // Buffer full !!
 }

 #define bkbhit (next_in!=next_out)

 BYTE bgetc()
 {
    BYTE c;

    while(!bkbhit) ;
    c=buffer[next_out];
    next_out=(next_out+1) % BUFFER_SIZE;
    return(c);
 }
 
 void inicbuff(void){ // Inicia a \0 cbuff -------------------
   int i;

   for(i=0;i<BUFFER_SIZE;i++){   // Bucle que pone a 0 todos los
     buffer[i]=0x00;          // caracteres en el buffer
   }
 
 }

 void main() {
     
    char palabra[BUFFER_SIZE];
    delay_ms(100);
    usb_init();
    delay_us(100);
    inicbuff(); // Borra buffer al inicio
   
    enable_interrupts(int_rda);
    enable_interrupts(global);
    int i=0;
    delay_ms(50);
   
    while(TRUE)
    {
        delay_ms(50);
        if(bkbhit)
            printf(usb_cdc_putc,"%c" ,bgetc());
 
        usb_task();
        if (usb_enumerated())
        {
            if (usb_cdc_kbhit())
            {
             
                printf(usb_cdc_putc,"\r\n");      //limpia la pantalla
                get_string_usb(palabra,BUFFER_SIZE);     //obtiene la palabra escrita en el teclado
                printf(usb_cdc_putc,"\r\n");
                inicbuff();
             
                if(palabra[0]!=0x00)
                    fputs(palabra,WIFI);                  //  manda la palabra del teclado al modulo
             
            }
           
        }
       
       
    }

 }




Happy new year
sebalitter



Joined: 05 May 2015
Posts: 47

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

PostPosted: Sun Jan 03, 2016 6:30 pm     Reply with quote

Hello, someone

Several posters on sparkfun report having problems passing data from PICs to the RN-171 device, but no-one mentions the possibility that an inverter is needed between the two to make the communication from PIC to RN-171 work.

The ploblem is that the RN171 dont receive data from the pic or it does with wrong data.


Someone had the same problem?

Thanks
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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