Hello,

I'm trying to use this litlle board => 
https://www.microchip.com/DevelopmentTools/ProductDetails/DM164143
Impossible to figure out why, I can't make it work with hardware libraries, 
either for serial or I2C.

With Serial (both UART 1 and 2): receive correctly but never transmit.
With I2C : program doesn't run at all !

BUT ! On the same pins, Software libraries work fine !

I tried all option I could find reading the datasheet, with no success...

I am not able to test on the chip alone (i.e without the developpement 
board) but I doubt this is the point.

Does this MC require the initialization of a special register ?

Thank you for your help!

Here is my code:

-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% 
                  %
-- % MPLAB xpress                                                           
               %
-- % Langage JAL 2.4                                                       
    %
-- % GBA 08/2019                                                           
    %
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%


include 16f15376                     -- target PICmicro


pragma target clock 20_000_000      -- oscillator frequency
--
pragma target OSC      HS                        -- crystal or resonator
pragma target RSTOSC   EXT1X                     -- power-up clock select: 
OSC
pragma target CLKOUTEN DISABLED                  -- no clock output
pragma target FCMEN    DISABLED                  -- no clock monitoring
pragma target CSWEN    ENABLED                   -- allow writing OSCCON1 
NOSC and NDIV
pragma target WDT      DISABLED                  -- watchdog
pragma target BROWNOUT DISABLED                  -- no brownout reset
pragma target LVP      DISABLED                  -- no low voltage 
programming
pragma target MCLR     EXTERNAL                  -- external reset




include delay
include print                          -- formatted output library


enable_digital_io()


TRISD = 0b00000000 -- RD0 => RD7 : sorties


-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
-- % Déclaration du bus I2C
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
-- I2C io definition
alias i2c_scl is pin_c3
alias pin_scl_direction  is pin_c3_direction
alias i2c_scl_direction  is pin_c3_direction


alias i2c_sda is pin_c4
alias pin_sda_direction  is pin_c4_direction
alias i2c_sda_direction  is pin_c4_direction


-- i2c setup
const word _i2c_bus_speed = 1 ; * 100kHz
const bit _i2c_level = true   ; i2c levels (not SMB;  i2c_hw only)
include i2c_hardware
-- include i2c_software
i2c_initialize()


-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
-- % FIN Déclaration du bus I2C
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%


-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
-- % Traitement de l'affichage LCD
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
const byte LCD_ROWS     = 2            -- 2 lines
const byte LCD_CHARS    = 16           -- 16 chars per line
const byte LCD_ADDRESS  = 0x7E         -- LCD module I2C address
include lcd_hd44780_pcf8574            -- LCD lib with serial interface
lcd_init()                             -- initialize LCD
lcd_backlight(on)


procedure lcd_print_at(byte in line, byte in pos, byte in str1[]) is
   line = line - 1
   pos = pos - 1
   lcd_cursor_position(line, pos)
   print_string(lcd, str1)
end procedure


lcd_print_at(1, 1, "Bienvenue")


-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
-- % FIN Traitement de l'affichage LCD
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%


-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
-- % Traitement des ports RS232
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
-- -- Définition des valeurs du port série
alias pin_RX_direction  is pin_C7_direction  -- Pin 26 for 40 pin DIP
alias pin_RX1_direction  is pin_C7_direction
alias pin_TX_direction  is pin_C6_direction  -- Pin 25 for 40 pin DIP
alias pin_TX1_direction  is pin_C6_direction


alias Serial_SW_RX_Pin  is pin_C7  -- Pin 26 for 40 pin DIP
alias Serial_SW_TX_Pin  is pin_C6  -- Pin 25 for 40 pin DIP
pin_RX_direction = INPUT
pin_TX_direction = OUTPUT


const USART_HW_Serial     = TRUE
const Serial_HW_Baudrate  = 9600
include Serial_Hardware
Serial_HW_Init


-- const USART_SW_Serial     = TRUE
-- const Serial_SW_Baudrate  = 9600
-- include Serial_Software
--
-- Serial_SW_Init


alias pin_RX2_direction is pin_B7_direction  -- Pin 40 for 40 pin DIP
alias pin_TX2_direction is pin_B6_direction  -- Pin 39 for 40 pin DIP
pin_RX2_direction = INPUT
pin_TX2_direction = OUTPUT


const USART_HW2_Serial    = TRUE
const serial_hw2_baudrate = 9600
include serial_hardware2


serial_hw2_init


-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
-- % FIN Traitement des ports RS232
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%


Alias LED_CLK is Pin_d4
pin_D4_direction = output -- clock
Alias LED_STB is Pin_d5
pin_D5_direction = output -- strobe
Alias LED_DAT is Pin_d6
pin_D6_direction = output -- data


-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
Procedure Led_Send(Byte*2 In Num) Is
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%


    Var Byte*2 Renum = Num
    Var Bit d0 at Renum:0


    LED_STB = LOW


    For 16 Loop
        delay_2us
        LED_CLK = 0
        delay_1us
        LED_DAT = d0
        delay_1us
        LED_CLK = 1
        delay_1us
        Renum = Renum >> 1
    End Loop


    LED_STB = HIGH
        delay_1us
    LED_STB = LOW


End Procedure


for 4 loop
    Led_Send(0b1111111111111111)
    delay_1ms(100)
    Led_Send(0b0000000000000000)
    delay_1ms(100)
end loop


var byte strb[1]
var Byte Data_Msg = 0


Forever Loop


    Led_Send(0b1000000000000000)
    delay_1ms(500)
    Led_Send(0b0000000000000000)
    delay_1ms(500)
    strb[0] = 65
    print_string(serial_hw_data, strb)
--    print_string(serial_sw_data, strb)
    delay_1ms(10)


end loop







-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/3cc921bf-b675-4a6f-a9d9-8a3febc100e6%40googlegroups.com.

Reply via email to